Class CamelExchangeException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CamelAuthorizationException, CamelUnitOfWorkException, ExchangeTimedOutException, InvalidPayloadException, NoSuchHeaderException, NoSuchHeaderOrPropertyException, NoSuchPropertyException, NoSuchVariableException, RollbackExchangeException, ValidationException

public class CamelExchangeException extends CamelException
A CamelException that carries the Exchange whose processing triggered the failure.

Used by Camel routing internals to attach exchange context to a failure so error handlers, the dead-letter channel and onException clauses can inspect headers, properties and the in-flight Message. The reference is transient because exchanges are not guaranteed to be serializable.

See Also:
  • Constructor Details

    • CamelExchangeException

      public CamelExchangeException(@Nullable String message, @Nullable Exchange exchange)
      Parameters:
      message - the detail message
      exchange - the exchange that caused the error
    • CamelExchangeException

      public CamelExchangeException(@Nullable String message, @Nullable Exchange exchange, @Nullable Throwable cause)
      Parameters:
      message - the detail message
      exchange - the exchange that caused the error
      cause - the cause of the failure
  • Method Details

    • getExchange

      public @Nullable Exchange getExchange()
      Returns the exchange which caused the exception
    • createExceptionMessage

      public static String createExceptionMessage(@Nullable String message, @Nullable Exchange exchange, @Nullable Throwable cause)
      Creates an exception message with the provided details.

      All fields is optional so you can pass in only an exception, or just a message etc. or any combination.

      Parameters:
      message - the message
      exchange - the exchange
      cause - the caused exception
      Returns:
      an error message (without stacktrace from exception)