Skip to content

Commit

Permalink
improve error message in case of schema mismatch (#789)
Browse files Browse the repository at this point in the history
Co-authored-by: nikita myazin <[email protected]>
  • Loading branch information
myazinn and nikita myazin authored Aug 29, 2023
1 parent f6c4704 commit e6305e3
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class SchemaFieldDecoder[T](param: magnolia1.CaseClass.Param[Decoder, T], schema

private val fieldName = Annotations(param.annotations).name.getOrElse(param.label)
private val fieldPosition = schema.getFields.asScala.indexWhere(_.name() == fieldName)
private val field = schema.getField(fieldName)
private val field =
Option(schema.getField(fieldName))
.getOrElse(throw new Avro4sDecodingException(s"""Field "$fieldName" not found in schema $schema""", fieldName))
private val decoder = param.typeclass.asInstanceOf[Decoder[T]].decode(field.schema())
private var fast: Boolean | Null = _

Expand Down

0 comments on commit e6305e3

Please sign in to comment.