Class CodecException

All Implemented Interfaces:
Serializable

public class CodecException extends RuntimeException
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 Details

    • CodecException

      public CodecException(String message, Throwable cause)
      Creates a new CodecException with the given message and cause.
      Parameters:
      message - the error message
      cause - the underlying cause
  • Method Details

    • withField

      public CodecException withField(String fieldName)
      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

      public CodecException withIndex(int index)
      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 batches reads batches[2].

      Parameters:
      index - the zero-based index of the failing item
      Returns:
      a new CodecException with the updated field path
    • getFieldPath

      public String 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

      public String getMessage()
      Overrides:
      getMessage in class Throwable