Class CodecException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
InvalidPayloadException, InvalidValueException, TransientCodecException, UnsupportedFormatException
Codec reports from Codec.encode(T) or Codec.decode(byte[]).
This class is never thrown directly; it exists for the coarse catch (CodecException e)
— "something went wrong in the codec". Its four subclasses are keyed to what the caller does
next, and a catch for one of them is the precise form:
InvalidValueException— the value handed toencodecannot be encoded: fix the value or the configuration.InvalidPayloadException— the payload handed todecodeis malformed, corrupt, or forged: quarantine it.UnsupportedFormatException— the payload is well-formed but this reader cannot handle it (a format version or algorithm it does not know): hold it, route it to a newer reader, or upgrade.TransientCodecException— something the codec depends on failed; the input is not at fault: retry, or alert on infrastructure.
The rule for extending the hierarchy: subclass by what the caller does next. A failure with one of the four answers above is a subclass of that family, never a fifth sibling. A more specific subclass earns its existence only when it carries information the family does not.
Construction and configuration errors — a bad builder argument, a null mapper, a type a
factory cannot create a codec for, a null passed to encode or decode —
are programmer errors at wiring time and remain IllegalArgumentException, IllegalStateException and NullPointerException; they are not codec failures.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCodecException(String message) Creates a codec failure with the given message; for subclasses.protectedCodecException(String message, Throwable cause) Creates a codec failure with the given message and cause; for subclasses. -
Method Summary
Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
CodecException
Creates a codec failure with the given message; for subclasses.- Parameters:
message- what went wrong, in plain words, never containing payload contents
-
CodecException
-