Class ExceptionConverter
java.lang.Object
io.axoniq.framework.axonserver.connector.shared.ExceptionConverter
Utility class used to serialize
Throwables into ErrorMessages, and to
reconstruct AxonExceptions from error information received over the wire.
This class is used by the command and query connector implementations; it is not meant to be used directly by application code.
- Since:
- 4.0.0
- Author:
- Marc Gathier
-
Method Summary
Modifier and TypeMethodDescriptionstatic AxonExceptionconvertToAxonException(String errorCode, io.axoniq.axonserver.grpc.ErrorMessage errorMessage, io.axoniq.axonserver.grpc.SerializedObject payload, @Nullable Converter converter) Converts the given error information into anAxonException, attaching the givenconverterso that the resulting exception's details can be converted, on request, into whatever type the caller needs (seeHandlerExecutionException#getDetails(Class)).static @Nullable io.axoniq.axonserver.grpc.SerializedObjectconvertToDetails(Throwable cause, @Nullable Converter converter) Converts the application-specific details carried by aHandlerExecutionExceptionin the cause chain of the givencause, if any, into aSerializedObjectsuitable for putting on the wire.static io.axoniq.axonserver.grpc.ErrorMessageconvertToErrorMessage(@Nullable String clientLocation, @Nullable ErrorCode errorCode, Throwable t) Convert a givenThrowableinto anErrorMessage.
-
Method Details
-
convertToAxonException
public static AxonException convertToAxonException(String errorCode, io.axoniq.axonserver.grpc.ErrorMessage errorMessage, io.axoniq.axonserver.grpc.SerializedObject payload, @Nullable Converter converter) Converts the given error information into anAxonException, attaching the givenconverterso that the resulting exception's details can be converted, on request, into whatever type the caller needs (seeHandlerExecutionException#getDetails(Class)).The
payload's raw bytes are not deserialized here. Deserialization is deferred until a caller asks for a specific details type, decoupling the thrower's details class (and version) from the receiver's.- Parameters:
errorCode- the error code identifying the type of exception to convert toerrorMessage- theErrorMessagecontaining details of the errorpayload- an optionalSerializedObjectrepresenting additional error data, which may be used in the exception conversionconverter- theConverterto attach to the resulting exception, so that details can be converted lazily, ornullif no such conversion is available- Returns:
- an instance of
AxonExceptionrepresenting the given error information
-
convertToDetails
public static @Nullable io.axoniq.axonserver.grpc.SerializedObject convertToDetails(Throwable cause, @Nullable Converter converter) Converts the application-specific details carried by aHandlerExecutionExceptionin the cause chain of the givencause, if any, into aSerializedObjectsuitable for putting on the wire.The
type/revisionon the resultingSerializedObjectcarry the runtime class name of the details object purely for wire-level observability/tracing. They are not used to reconstruct the details on the receiving side, since reconstruction is driven entirely by the type the receiver asks for.- Parameters:
cause- the exception to resolve application-specific details fromconverter- theConverterused to serialize the details into bytes, ornullif none is available- Returns:
- a
SerializedObjectcarrying the serialized details, ornullif there are no details, or the details could not be serialized
-