@@ -8,6 +8,7 @@ import java.util.{Map => JMap}
88import java .util .Collection
99
1010import com .exasol .common .json .JsonMapper
11+ import com .exasol .errorreporting .ExaError
1112
1213import org .apache .avro .Conversions .DecimalConversion
1314import org .apache .avro .LogicalTypes
@@ -121,8 +122,13 @@ final class AvroConverter {
121122 val precision = logicalType.getPrecision()
122123 if (precision > EXASOL_DECIMAL_PRECISION ) {
123124 throw new IllegalArgumentException (
124- s " Decimal precision ${precision.toString()} is larger than " +
125- s " maximum allowed precision ${EXASOL_DECIMAL_PRECISION .toString()}. "
125+ ExaError
126+ .messageBuilder(" E-IEUCS-5" )
127+ .message(" Decimal precision {{PRECISION}} is larger than maximal allowed {{ALLOWED}} precision." )
128+ .parameter(" PRECISION" , precision.toString())
129+ .parameter(" ALLOWED" , EXASOL_DECIMAL_PRECISION .toString())
130+ .mitigation(" Please ensure that Avro decimal value precision fits into Exasol decimal precision." )
131+ .toString()
126132 )
127133 }
128134 }
@@ -136,7 +142,11 @@ final class AvroConverter {
136142 case fixed : GenericFixed => new String (fixed.bytes(), " UTF8" )
137143 case _ =>
138144 throw new IllegalArgumentException (
139- s " Avro ${field.getName} type cannot be converted to string! "
145+ ExaError
146+ .messageBuilder(" E-IEUCS-6" )
147+ .message(" Avro field {{FIELD}} type cannot be converted to string." , field.getName())
148+ .mitigation(" Please ensure that Exasol table column and Avro field types match." )
149+ .toString()
140150 )
141151 }
142152
@@ -151,15 +161,19 @@ final class AvroConverter {
151161 } else if (types.get(1 ).getType() == Schema .Type .NULL ) {
152162 getAvroValue(value, types.get(0 ))
153163 } else {
154- throw new IllegalArgumentException (
155- " Avro Union type should contain a primitive and null!"
156- )
164+ throw new IllegalArgumentException (getAvroUnionErrorMessage())
157165 }
158- case _ =>
159- throw new IllegalArgumentException (" Avro Union type should contain a primitive and null!" )
166+ case _ => throw new IllegalArgumentException (getAvroUnionErrorMessage())
160167 }
161168 }
162169
170+ private [this ] def getAvroUnionErrorMessage (): String =
171+ ExaError
172+ .messageBuilder(" E-IEUCS-7" )
173+ .message(" Avro union type does not contain a primitive type and null." )
174+ .mitigation(" Please make sure that Avro union type contains a primitive type and a null." )
175+ .toString()
176+
163177 private [this ] def getArrayValue (value : Any , field : Schema ): Array [Any ] = value match {
164178 case array : Array [_] => array.map(getAvroValue(_, field.getElementType()))
165179 case list : Collection [_] =>
@@ -172,7 +186,12 @@ final class AvroConverter {
172186 result
173187 case other =>
174188 throw new IllegalArgumentException (
175- s " Unsupported Avro Array type ' ${other.getClass.getName()}'. "
189+ ExaError
190+ .messageBuilder(" E-IEUCS-8" )
191+ .message(" Unsupported Avro array type {{TYPE}}." , other.getClass.getName())
192+ .mitigation(" Please make sure Avro array type is of Array or Collection types." )
193+ .ticketMitigation()
194+ .toString()
176195 )
177196 }
178197
@@ -201,7 +220,12 @@ final class AvroConverter {
201220 result
202221 case other =>
203222 throw new IllegalArgumentException (
204- s " Unsupported Avro Record type ' ${other.getClass.getName()}'. "
223+ ExaError
224+ .messageBuilder(" E-IEUCS-9" )
225+ .message(" Unsupported Avro record type {{TYPE}}." , other.getClass.getName())
226+ .mitigation(" Please make sure that Avro record type is of IndexedRecord type." )
227+ .ticketMitigation()
228+ .toString()
205229 )
206230 }
207231
0 commit comments