1use crate::{
19 schema::{Name, Schema, SchemaKind, UnionSchema},
20 types::{Value, ValueKind},
21};
22use std::{error::Error as _, fmt};
23
24#[derive(thiserror::Error, Debug)]
31#[repr(transparent)]
32#[error(transparent)]
33pub struct Error {
34 details: Box<Details>,
35}
36
37impl Error {
38 pub fn new(details: Details) -> Self {
39 Self {
40 details: Box::new(details),
41 }
42 }
43
44 pub fn details(&self) -> &Details {
45 &self.details
46 }
47
48 pub fn into_details(self) -> Details {
49 *self.details
50 }
51}
52
53impl From<Details> for Error {
54 fn from(details: Details) -> Self {
55 Self::new(details)
56 }
57}
58
59impl serde::ser::Error for Error {
60 fn custom<T: fmt::Display>(msg: T) -> Self {
61 Self::new(<Details as serde::ser::Error>::custom(msg))
62 }
63}
64
65impl serde::de::Error for Error {
66 fn custom<T: fmt::Display>(msg: T) -> Self {
67 Self::new(<Details as serde::de::Error>::custom(msg))
68 }
69}
70
71#[derive(thiserror::Error)]
72pub enum Details {
73 #[error("Bad Snappy CRC32; expected {expected:x} but got {actual:x}")]
74 SnappyCrc32 { expected: u32, actual: u32 },
75
76 #[error("Invalid u8 for bool: {0}")]
77 BoolValue(u8),
78
79 #[error("Not a fixed value, required for decimal with fixed schema: {0:?}")]
80 FixedValue(Value),
81
82 #[error("Not a bytes value, required for decimal with bytes schema: {0:?}")]
83 BytesValue(Value),
84
85 #[error("Not a string value, required for uuid: {0:?}")]
86 GetUuidFromStringValue(Value),
87
88 #[error("Two schemas with the same fullname were given: {0:?}")]
89 NameCollision(String),
90
91 #[error("Not a fixed or bytes type, required for decimal schema, got: {0:?}")]
92 ResolveDecimalSchema(SchemaKind),
93
94 #[error("Invalid utf-8 string")]
95 ConvertToUtf8(#[source] std::string::FromUtf8Error),
96
97 #[error("Invalid utf-8 string")]
98 ConvertToUtf8Error(#[source] std::str::Utf8Error),
99
100 #[error("Value does not match schema")]
102 Validation,
103
104 #[error("Value {value:?} does not match schema {schema:?}: Reason: {reason}")]
106 ValidationWithReason {
107 value: Value,
108 schema: Schema,
109 reason: String,
110 },
111
112 #[error(
113 "Unable to allocate {desired} bytes (maximum allowed: {maximum}). Change the limit using `apache_avro::util::max_allocation_bytes`"
114 )]
115 MemoryAllocation { desired: usize, maximum: usize },
116
117 #[error(
119 "Number of bytes requested for decimal sign extension {requested} is less than the number of bytes needed to decode {needed}"
120 )]
121 SignExtend { requested: usize, needed: usize },
122
123 #[error("Failed to read boolean bytes: {0}")]
124 ReadBoolean(#[source] std::io::Error),
125
126 #[error("Failed to read bytes: {0}")]
127 ReadBytes(#[source] std::io::Error),
128
129 #[error("Failed to read string: {0}")]
130 ReadString(#[source] std::io::Error),
131
132 #[error("Failed to read double: {0}")]
133 ReadDouble(#[source] std::io::Error),
134
135 #[error("Failed to read float: {0}")]
136 ReadFloat(#[source] std::io::Error),
137
138 #[error("Failed to read duration: {0}")]
139 ReadDuration(#[source] std::io::Error),
140
141 #[error("Failed to read fixed number of bytes '{1}': : {0}")]
142 ReadFixed(#[source] std::io::Error, usize),
143
144 #[error("Failed to convert &str to UUID: {0}")]
145 ConvertStrToUuid(#[source] uuid::Error),
146
147 #[error("Failed to convert Fixed bytes to UUID. It must be exactly 16 bytes, got {0}")]
148 ConvertFixedToUuid(usize),
149
150 #[error("Failed to convert Fixed bytes to UUID: {0}")]
151 ConvertSliceToUuid(#[source] uuid::Error),
152
153 #[error("Map key is not a string; key type is {0:?}")]
154 MapKeyType(ValueKind),
155
156 #[error("Union index {index} out of bounds: {num_variants}")]
157 GetUnionVariant { index: i64, num_variants: usize },
158
159 #[deprecated(since = "0.20.0", note = "This error variant is not generated anymore")]
160 #[error("Enum symbol index out of bounds: {num_variants}")]
161 EnumSymbolIndex { index: usize, num_variants: usize },
162
163 #[error("Enum symbol not found {0}")]
164 GetEnumSymbol(String),
165
166 #[error("Unable to decode enum index")]
167 GetEnumUnknownIndexValue,
168
169 #[error("Scale {scale} is greater than precision {precision}")]
170 GetScaleAndPrecision { scale: usize, precision: usize },
171
172 #[error(
173 "Fixed type number of bytes {size} is not large enough to hold decimal values of precision {precision}"
174 )]
175 GetScaleWithFixedSize { size: usize, precision: usize },
176
177 #[error("Expected Value::Uuid, got: {0:?}")]
178 GetUuid(Value),
179
180 #[error("Expected Value::BigDecimal, got: {0:?}")]
181 GetBigDecimal(Value),
182
183 #[error("Fixed bytes of size 12 expected, got Fixed of size {0}")]
184 GetDurationFixedBytes(usize),
185
186 #[error("Expected Value::Duration or Value::Fixed(12), got: {0:?}")]
187 ResolveDuration(Value),
188
189 #[error("Expected Value::Decimal, Value::Bytes or Value::Fixed, got: {0:?}")]
190 ResolveDecimal(Value),
191
192 #[error("Missing field in record: {0:?}")]
193 GetField(String),
194
195 #[error("Unable to convert to u8, got {0:?}")]
196 GetU8(Value),
197
198 #[error("Precision {precision} too small to hold decimal values with {num_bytes} bytes")]
199 ComparePrecisionAndSize { precision: usize, num_bytes: usize },
200
201 #[error("Cannot convert length to i32: {1}")]
202 ConvertLengthToI32(#[source] std::num::TryFromIntError, usize),
203
204 #[error("Expected Value::Date or Value::Int, got: {0:?}")]
205 GetDate(Value),
206
207 #[error("Expected Value::TimeMillis or Value::Int, got: {0:?}")]
208 GetTimeMillis(Value),
209
210 #[error("Expected Value::TimeMicros, Value::Long or Value::Int, got: {0:?}")]
211 GetTimeMicros(Value),
212
213 #[error("Expected Value::TimestampMillis, Value::Long or Value::Int, got: {0:?}")]
214 GetTimestampMillis(Value),
215
216 #[error("Expected Value::TimestampMicros, Value::Long or Value::Int, got: {0:?}")]
217 GetTimestampMicros(Value),
218
219 #[error("Expected Value::TimestampNanos, Value::Long or Value::Int, got: {0:?}")]
220 GetTimestampNanos(Value),
221
222 #[error("Expected Value::LocalTimestampMillis, Value::Long or Value::Int, got: {0:?}")]
223 GetLocalTimestampMillis(Value),
224
225 #[error("Expected Value::LocalTimestampMicros, Value::Long or Value::Int, got: {0:?}")]
226 GetLocalTimestampMicros(Value),
227
228 #[error("Expected Value::LocalTimestampNanos, Value::Long or Value::Int, got: {0:?}")]
229 GetLocalTimestampNanos(Value),
230
231 #[error("Expected Value::Null, got: {0:?}")]
232 GetNull(Value),
233
234 #[error("Expected Value::Boolean, got: {0:?}")]
235 GetBoolean(Value),
236
237 #[error("Expected Value::Int, got: {0:?}")]
238 GetInt(Value),
239
240 #[error("Expected Value::Long or Value::Int, got: {0:?}")]
241 GetLong(Value),
242
243 #[error(r#"Expected Value::Double, Value::Float, Value::Int, Value::Long or Value::String ("NaN", "INF", "Infinity", "-INF" or "-Infinity"), got: {0:?}"#)]
244 GetDouble(Value),
245
246 #[error(r#"Expected Value::Float, Value::Double, Value::Int, Value::Long or Value::String ("NaN", "INF", "Infinity", "-INF" or "-Infinity"), got: {0:?}"#)]
247 GetFloat(Value),
248
249 #[error("Expected Value::Bytes, got: {0:?}")]
250 GetBytes(Value),
251
252 #[error("Expected Value::String, Value::Bytes or Value::Fixed, got: {0:?}")]
253 GetString(Value),
254
255 #[error("Expected Value::Enum, got: {0:?}")]
256 GetEnum(Value),
257
258 #[error("Fixed size mismatch, expected: {size}, got: {n}")]
259 CompareFixedSizes { size: usize, n: usize },
260
261 #[error("String expected for fixed, got: {0:?}")]
262 GetStringForFixed(Value),
263
264 #[error("Enum default {symbol:?} is not among allowed symbols {symbols:?}")]
265 GetEnumDefault {
266 symbol: String,
267 symbols: Vec<String>,
268 },
269
270 #[error("Enum value index {index} is out of bounds {nsymbols}")]
271 GetEnumValue { index: usize, nsymbols: usize },
272
273 #[error("Key {0} not found in decimal metadata JSON")]
274 GetDecimalMetadataFromJson(&'static str),
275
276 #[error("Could not find matching type in {schema:?} for {value:?}")]
277 FindUnionVariant { schema: UnionSchema, value: Value },
278
279 #[error("Union type should not be empty")]
280 EmptyUnion,
281
282 #[error("Array({expected:?}) expected, got {other:?}")]
283 GetArray { expected: SchemaKind, other: Value },
284
285 #[error("Map({expected:?}) expected, got {other:?}")]
286 GetMap { expected: SchemaKind, other: Value },
287
288 #[error("Record with fields {expected:?} expected, got {other:?}")]
289 GetRecord {
290 expected: Vec<(String, SchemaKind)>,
291 other: Value,
292 },
293
294 #[error("No `name` field")]
295 GetNameField,
296
297 #[error("No `name` in record field")]
298 GetNameFieldFromRecord,
299
300 #[error("Unions may not directly contain a union")]
301 GetNestedUnion,
302
303 #[error("Unions cannot contain duplicate types")]
304 GetUnionDuplicate,
305
306 #[error("Unions cannot contain more than one named schema with the same name: {0}")]
307 GetUnionDuplicateNamedSchemas(String),
308
309 #[error("One union type {0:?} must match the `default`'s value type {1:?}")]
310 GetDefaultUnion(SchemaKind, ValueKind),
311
312 #[error("`default`'s value type of field {0:?} in {1:?} must be {2:?}")]
313 GetDefaultRecordField(String, String, String),
314
315 #[error("JSON number {0} could not be converted into an Avro value as it's too large")]
316 JsonNumberTooLarge(serde_json::Number),
317
318 #[error("JSON value {0} claims to be u64 but cannot be converted")]
319 GetU64FromJson(serde_json::Number),
320
321 #[error("JSON value {0} claims to be i64 but cannot be converted")]
322 GetI64FromJson(serde_json::Number),
323
324 #[error("Cannot convert u64 to usize: {1}")]
325 ConvertU64ToUsize(#[source] std::num::TryFromIntError, u64),
326
327 #[deprecated(since = "0.20.0", note = "This error variant is not generated anymore")]
328 #[error("Cannot convert u32 to usize: {1}")]
329 ConvertU32ToUsize(#[source] std::num::TryFromIntError, u32),
330
331 #[error("Cannot convert i64 to usize: {1}")]
332 ConvertI64ToUsize(#[source] std::num::TryFromIntError, i64),
333
334 #[error("Cannot convert i32 to usize: {1}")]
335 ConvertI32ToUsize(#[source] std::num::TryFromIntError, i32),
336
337 #[error("Cannot convert i64 to u64: {1}")]
338 ConvertI64ToU64(#[source] std::num::TryFromIntError, i64),
339
340 #[error("Cannot convert i32 to u64: {1}")]
341 ConvertI32ToU64(#[source] std::num::TryFromIntError, i32),
342
343 #[error("Cannot convert i64 to u128: {1}")]
344 ConvertI64ToU128(#[source] std::num::TryFromIntError, i64),
345
346 #[error("Cannot convert i32 to u128: {1}")]
347 ConvertI32ToU128(#[source] std::num::TryFromIntError, i32),
348
349 #[error("Cannot convert usize to i64: {1}")]
350 ConvertUsizeToI64(#[source] std::num::TryFromIntError, usize),
351
352 #[error("Invalid JSON value for decimal precision/scale integer: {0}")]
353 GetPrecisionOrScaleFromJson(serde_json::Number),
354
355 #[error("Failed to parse schema from JSON")]
356 ParseSchemaJson(#[source] serde_json::Error),
357
358 #[error("Failed to read schema")]
359 ReadSchemaFromReader(#[source] std::io::Error),
360
361 #[error("Must be a JSON string, object or array")]
362 ParseSchemaFromValidJson,
363
364 #[error("Unknown primitive type: {0}")]
365 ParsePrimitive(String),
366
367 #[error("Unknown primitive type: '{0}'. Did you mean '{1}' ?")]
368 ParsePrimitiveSimilar(String, &'static str),
369
370 #[error("invalid JSON for {key:?}: {value:?}")]
371 GetDecimalMetadataValueFromJson {
372 key: String,
373 value: serde_json::Value,
374 },
375
376 #[error("The decimal precision ({precision}) must be bigger or equal to the scale ({scale})")]
377 DecimalPrecisionLessThanScale { precision: usize, scale: usize },
378
379 #[error("The decimal precision ({precision}) must be a positive number")]
380 DecimalPrecisionMuBePositive { precision: usize },
381
382 #[deprecated(since = "0.20.0", note = "This error variant is not generated anymore")]
383 #[error("Unreadable big decimal sign")]
384 BigDecimalSign,
385
386 #[error("Unreadable length for big decimal inner bytes: {0}")]
387 BigDecimalLen(#[source] Box<Error>),
388
389 #[error("Unreadable big decimal scale")]
390 BigDecimalScale,
391
392 #[deprecated(since = "0.20.0", note = "This error variant is not generated anymore")]
393 #[error("Unexpected `type` {0} variant for `logicalType`")]
394 GetLogicalTypeVariant(serde_json::Value),
395
396 #[error("No `type` field found for `logicalType`")]
397 GetLogicalTypeField,
398
399 #[error("logicalType must be a string, but is {0:?}")]
400 GetLogicalTypeFieldType(serde_json::Value),
401
402 #[error("Unknown complex type: {0}")]
403 GetComplexType(serde_json::Value),
404
405 #[error("No `type` in complex type")]
406 GetComplexTypeField,
407
408 #[error("No `fields` in record")]
409 GetRecordFieldsJson,
410
411 #[error("No `symbols` field in enum")]
412 GetEnumSymbolsField,
413
414 #[error("Unable to parse `symbols` in enum")]
415 GetEnumSymbols,
416
417 #[error("Invalid enum symbol name {0}")]
418 EnumSymbolName(String),
419
420 #[error("Invalid field name {0}")]
421 FieldName(String),
422
423 #[error("Duplicate field name {0}")]
424 FieldNameDuplicate(String),
425
426 #[error("Invalid schema name {0}. It must match the regex '{1}'")]
427 InvalidSchemaName(String, &'static str),
428
429 #[error("Invalid namespace {0}. It must match the regex '{1}'")]
430 InvalidNamespace(String, &'static str),
431
432 #[error(
433 "Invalid schema: There is no type called '{0}', if you meant to define a non-primitive schema, it should be defined inside `type` attribute. Please review the specification"
434 )]
435 InvalidSchemaRecord(String),
436
437 #[error("Duplicate enum symbol {0}")]
438 EnumSymbolDuplicate(String),
439
440 #[error("Default value for an enum must be a string! Got: {0}")]
441 EnumDefaultWrongType(serde_json::Value),
442
443 #[error("Default value for an array must be an array! Got: {0}")]
444 ArrayDefaultWrongType(serde_json::Value),
445
446 #[error("Default value for an array must be an array of {0}! Found: {1:?}")]
447 ArrayDefaultWrongInnerType(Schema, Value),
448
449 #[error("Default value for a map must be an object! Got: {0}")]
450 MapDefaultWrongType(serde_json::Value),
451
452 #[error("Default value for a map must be an object with (String, {0})! Found: (String, {1:?})")]
453 MapDefaultWrongInnerType(Schema, Value),
454
455 #[error("No `items` in array")]
456 GetArrayItemsField,
457
458 #[error("No `values` in map")]
459 GetMapValuesField,
460
461 #[error("Fixed schema `size` value must be a positive integer: {0}")]
462 GetFixedSizeFieldPositive(serde_json::Value),
463
464 #[error("Fixed schema has no `size`")]
465 GetFixedSizeField,
466
467 #[deprecated(since = "0.22.0", note = "This error variant is not generated anymore")]
468 #[error("Fixed schema's default value length ({0}) does not match its size ({1})")]
469 FixedDefaultLenSizeMismatch(usize, u64),
470
471 #[deprecated(since = "0.20.0", note = "This error variant is not generated anymore")]
472 #[error("Failed to compress with flate: {0}")]
473 DeflateCompress(#[source] std::io::Error),
474
475 #[deprecated(since = "0.19.0", note = "This error can no longer occur")]
477 #[error("Failed to finish flate compressor: {0}")]
478 DeflateCompressFinish(#[source] std::io::Error),
479
480 #[error("Failed to decompress with flate: {0}")]
481 DeflateDecompress(#[source] std::io::Error),
482
483 #[cfg(feature = "snappy")]
484 #[error("Failed to compress with snappy: {0}")]
485 SnappyCompress(#[source] snap::Error),
486
487 #[cfg(feature = "snappy")]
488 #[error("Failed to get snappy decompression length: {0}")]
489 GetSnappyDecompressLen(#[source] snap::Error),
490
491 #[cfg(feature = "snappy")]
492 #[error("Failed to decompress with snappy: {0}")]
493 SnappyDecompress(#[source] snap::Error),
494
495 #[error("Failed to compress with zstd: {0}")]
496 ZstdCompress(#[source] std::io::Error),
497
498 #[error("Failed to decompress with zstd: {0}")]
499 ZstdDecompress(#[source] std::io::Error),
500
501 #[error("Failed to read header: {0}")]
502 ReadHeader(#[source] std::io::Error),
503
504 #[error("wrong magic in header")]
505 HeaderMagic,
506
507 #[error("Message Header mismatch. Expected: {0:?}. Actual: {1:?}")]
508 SingleObjectHeaderMismatch(Vec<u8>, Vec<u8>),
509
510 #[error("Failed to get JSON from avro.schema key in map")]
511 GetAvroSchemaFromMap,
512
513 #[error("no metadata in header")]
514 GetHeaderMetadata,
515
516 #[error("Failed to read marker bytes: {0}")]
517 ReadMarker(#[source] std::io::Error),
518
519 #[error("Failed to read block marker bytes: {0}")]
520 ReadBlockMarker(#[source] std::io::Error),
521
522 #[error("Read into buffer failed: {0}")]
523 ReadIntoBuf(#[source] std::io::Error),
524
525 #[error(
526 "Invalid sync marker! The sync marker in the data block \
527 doesn't match the file header's sync marker. This likely \
528 indicates data corruption, truncated file, or incorrectly \
529 concatenated Avro files. Verify file integrity and ensure \
530 proper file transmission or creation."
531 )]
532 GetBlockMarker,
533
534 #[error("Overflow when decoding integer value")]
535 IntegerOverflow,
536
537 #[error("Failed to read bytes for decoding variable length integer: {0}")]
538 ReadVariableIntegerBytes(#[source] std::io::Error),
539
540 #[error("Decoded integer out of range for i32: {1}: {0}")]
541 ZagI32(#[source] std::num::TryFromIntError, i64),
542
543 #[error("unable to read block")]
544 ReadBlock,
545
546 #[error("Failed to serialize value into Avro value: {0}")]
547 SerializeValue(String),
548
549 #[error("Failed to serialize value of type {value_type} using schema {schema:?}: {value}")]
550 SerializeValueWithSchema {
551 value_type: &'static str,
552 value: String,
553 schema: Schema,
554 },
555
556 #[error("Failed to serialize field '{field_name}' for record {record_schema:?}: {error}")]
557 SerializeRecordFieldWithSchema {
558 field_name: String,
559 record_schema: Schema,
560 error: Box<Error>,
561 },
562
563 #[error("Missing default for skipped field '{field_name}' for schema {schema:?}")]
564 MissingDefaultForSkippedField { field_name: String, schema: Schema },
565
566 #[error("Failed to deserialize Avro value into value: {0}")]
567 DeserializeValue(String),
568
569 #[error("Failed to write buffer bytes during flush: {0}")]
570 WriteBytes(#[source] std::io::Error),
571
572 #[error("Failed to flush inner writer during flush: {0}")]
573 FlushWriter(#[source] std::io::Error),
574
575 #[error("Failed to write marker: {0}")]
576 WriteMarker(#[source] std::io::Error),
577
578 #[error("Failed to convert JSON to string: {0}")]
579 ConvertJsonToString(#[source] serde_json::Error),
580
581 #[error("failed to convert avro float to json: {0}")]
583 ConvertF64ToJson(f64),
584
585 #[error("Unresolved schema reference: {0}")]
587 SchemaResolutionError(Name),
588
589 #[error("The file metadata is already flushed.")]
590 FileHeaderAlreadyWritten,
591
592 #[error("Metadata keys starting with 'avro.' are reserved for internal usage: {0}.")]
593 InvalidMetadataKey(String),
594
595 #[error("Two named schema defined for same fullname: {0}.")]
597 AmbiguousSchemaDefinition(Name),
598
599 #[error("Signed decimal bytes length {0} not equal to fixed schema size {1}.")]
600 EncodeDecimalAsFixedError(usize, usize),
601
602 #[error("There is no entry for '{0}' in the lookup table: {1}.")]
603 NoEntryInLookupTable(String, String),
604
605 #[error("Can only encode value type {value_kind:?} as one of {supported_schema:?}")]
606 EncodeValueAsSchemaError {
607 value_kind: ValueKind,
608 supported_schema: Vec<SchemaKind>,
609 },
610 #[error("Internal buffer not drained properly. Re-initialize the single object writer struct!")]
611 IllegalSingleObjectWriterState,
612
613 #[error("Codec '{0}' is not supported/enabled")]
614 CodecNotSupported(String),
615
616 #[error("Invalid Avro data! Cannot read codec type from value that is not Value::Bytes.")]
617 BadCodecMetadata,
618
619 #[error("Cannot convert a slice to Uuid: {0}")]
620 UuidFromSlice(#[source] uuid::Error),
621
622 #[error("Expected String for Map key when serializing a flattened struct")]
623 MapFieldExpectedString,
624
625 #[error("No key for value when serializing a map")]
626 MapNoKey,
627}
628
629#[derive(thiserror::Error, PartialEq)]
630pub enum CompatibilityError {
631 #[error(
632 "Incompatible schema types! Writer schema is '{writer_schema_type}', but reader schema is '{reader_schema_type}'"
633 )]
634 WrongType {
635 writer_schema_type: String,
636 reader_schema_type: String,
637 },
638
639 #[error("Incompatible schema types! The {schema_type} should have been {expected_type:?}")]
640 TypeExpected {
641 schema_type: String,
642 expected_type: Vec<SchemaKind>,
643 },
644
645 #[error(
646 "Incompatible schemata! Field '{0}' in reader schema does not match the type in the writer schema"
647 )]
648 FieldTypeMismatch(String, #[source] Box<CompatibilityError>),
649
650 #[error("Incompatible schemata! Field '{0}' in reader schema must have a default value")]
651 MissingDefaultValue(String),
652
653 #[error("Incompatible schemata! Reader's symbols contain none of the writer's symbols")]
654 MissingSymbols,
655
656 #[error("Incompatible schemata! All elements in union must match for both schemas")]
657 MissingUnionElements,
658
659 #[error("Incompatible schemata! At least one element in the union must match the schema")]
660 SchemaMismatchAllUnionElements,
661
662 #[error("Incompatible schemata! Size doesn't match for fixed")]
663 FixedMismatch,
664
665 #[error(
666 "Incompatible schemata! Decimal precision and/or scale don't match, reader: ({r_precision},{r_scale}), writer: ({w_precision},{w_scale})"
667 )]
668 DecimalMismatch {
669 r_precision: usize,
670 r_scale: usize,
671 w_precision: usize,
672 w_scale: usize,
673 },
674
675 #[error(
676 "Incompatible schemata! The name must be the same for both schemas. Writer's name {writer_name} and reader's name {reader_name}"
677 )]
678 NameMismatch {
679 writer_name: String,
680 reader_name: String,
681 },
682
683 #[error(
684 "Incompatible schemata! Unknown type for '{0}'. Make sure that the type is a valid one"
685 )]
686 Inconclusive(String),
687}
688
689impl serde::ser::Error for Details {
690 fn custom<T: fmt::Display>(msg: T) -> Self {
691 Details::SerializeValue(msg.to_string())
692 }
693}
694
695impl serde::de::Error for Details {
696 fn custom<T: fmt::Display>(msg: T) -> Self {
697 Details::DeserializeValue(msg.to_string())
698 }
699}
700
701impl fmt::Debug for Details {
702 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
703 let mut msg = self.to_string();
704 if let Some(e) = self.source() {
705 msg.extend([": ", &e.to_string()]);
706 }
707 write!(f, "{msg}")
708 }
709}
710
711impl fmt::Debug for CompatibilityError {
712 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
713 let mut msg = self.to_string();
714 if let Some(e) = self.source() {
715 msg.extend([": ", &e.to_string()]);
716 }
717 write!(f, "{msg}")
718 }
719}