spring-framework / org.springframework.messaging.support / ErrorMessage

ErrorMessage

open class ErrorMessage : GenericMessage<Throwable>

A GenericMessage with a Throwable payload.

The payload is typically a org.springframework.messaging.MessagingException with the message at the point of failure in its failedMessage property. An optional originalMessage may be provided, which represents the message that existed at the point in the stack where the error message is created.

Consider some code that starts with a message, invokes some process that performs transformation on that message and then fails for some reason, throwing the exception. The exception is caught and an error message produced that contains both the original message, and the transformed message that failed.

Author
Mark Fisher

Author
Oleg Zhurakousky

Author
Gary Russell

Since
4.0

See Also
MessageBuilder

Constructors

<init>

ErrorMessage(payload: Throwable)

Create a new message with the given payload.

ErrorMessage(payload: Throwable, headers: MutableMap<String, Any>)

Create a new message with the given payload and headers. The content of the given header map is copied.

ErrorMessage(payload: Throwable, headers: MessageHeaders)

A constructor with the MessageHeaders instance to use.

Note: the given MessageHeaders instance is used directly in the new message, i.e. it is not copied.

ErrorMessage(payload: Throwable, originalMessage: Message<*>)

Create a new message with the given payload and original message.

ErrorMessage(payload: Throwable, headers: MutableMap<String, Any>, originalMessage: Message<*>)

Create a new message with the given payload, headers and original message. The content of the given header map is copied.

ErrorMessage(payload: Throwable, headers: MessageHeaders, originalMessage: Message<*>)

Create a new message with the payload, MessageHeaders and original message.

Note: the given MessageHeaders instance is used directly in the new message, i.e. it is not copied.

Functions

getOriginalMessage

open fun getOriginalMessage(): Message<*>

Return the original message (if available) at the point in the stack where the ErrorMessage was created.

toString

open fun toString(): String