Class CodecException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.bytestreams.codec.core.CodecException
- All Implemented Interfaces:
Serializable
Exception thrown when encoding or decoding fails.
This exception accumulates field path information as it propagates through nested codecs,
providing clear error messages like: field [order.customer.name]: End of stream reached
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCodecException(String message, Throwable cause) Creates a new CodecException with the given message and cause. -
Method Summary
Modifier and TypeMethodDescriptionReturns the field path, with list indices attached to the field they belong to.Creates a new CodecException with the field name prepended to the path.withIndex(int index) Creates a new CodecException with a list index prepended to the path.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
CodecException
-
-
Method Details
-
withField
Creates a new CodecException with the field name prepended to the path.- Parameters:
fieldName- the field name to prepend- Returns:
- a new CodecException with the updated field path
-
withIndex
Creates a new CodecException with a list index prepended to the path.Indices attach to the preceding field name rather than forming their own segment, so a failure in the third item of
batchesreadsbatches[2].- Parameters:
index- the zero-based index of the failing item- Returns:
- a new CodecException with the updated field path
-
getFieldPath
Returns the field path, with list indices attached to the field they belong to.- Returns:
- the field path such as
batches[3].details[112].amount, or empty string if no path
-
getMessage
- Overrides:
getMessagein classThrowable
-