#[non_exhaustive]pub enum CamelError {
Show 27 variants
ComponentNotFound(String),
EndpointCreationFailed(String),
EndpointCreationFailedWithSource(String, OpaqueErrorSource),
ProcessorError(String),
ProcessorErrorWithSource(String, Arc<dyn Error + Send + Sync>),
TypeConversionFailed(String),
InvalidUri(String),
ChannelClosed,
RouteError(String),
Io(String),
DeadLetterChannelFailed(String),
CircuitOpen(String),
HttpOperationFailed {
method: String,
url: String,
status_code: u16,
status_text: String,
response_body: Option<String>,
},
ConsumerStopping,
Config(String),
ConfigValidation(ConfigValidationError),
AlreadyConsumed,
StreamLimitExceeded(usize),
Unauthenticated(String),
Unauthorized(String),
AuthProviderUnavailable(String),
ValidationError(String),
TemplateReload(String),
EndpointUri(EndpointUriError),
UnsupportedMediaType {
consumed: String,
declared: String,
},
NotAcceptable {
accept: String,
produced: String,
},
ExpressionFailed {
language: String,
route_id: String,
step_id: String,
verb: String,
class: ExpressionErrorClass,
position: Option<ErrorPosition>,
conversion: Option<ConversionDetail>,
cause: Option<Box<CamelError>>,
},
}Expand description
Core error type for the Camel framework.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
ComponentNotFound(String)
EndpointCreationFailed(String)
EndpointCreationFailedWithSource(String, OpaqueErrorSource)
Like EndpointCreationFailed but preserves the source error chain
for downstream inspection (e.g. typed gate-rejection classification).
ProcessorError(String)
ProcessorErrorWithSource(String, Arc<dyn Error + Send + Sync>)
Like ProcessorError but preserves the source error chain
for downstream inspection (e.g. via std::error::Error::source()).
TypeConversionFailed(String)
InvalidUri(String)
ChannelClosed
RouteError(String)
Io(String)
DeadLetterChannelFailed(String)
CircuitOpen(String)
HttpOperationFailed
Fields
ConsumerStopping
Producer call() failed on a shutdown signal — the consumer/semaphore
is closing and the producer cannot acquire a permit. Distinct from Stop EIP
(which is successful control flow). Used by JMS/OpenSearch producers. See ADR-0024.
Config(String)
ConfigValidation(ConfigValidationError)
Typed security-validation error (ADR-0033). Promotes Batch 1+ config/startup
failure modes from stringly-typed Config(_) to a matchable enum so
operators can discriminate programmatically.
AlreadyConsumed
StreamLimitExceeded(usize)
Unauthenticated(String)
Auth provider (JWKS/introspection/token endpoint) is unreachable or failing. Promotes the auth-provider-down signal from a stringly-typed ProcessorError to a matchable variant; WebSocket and gRPC transports map it to 503 / UNAVAILABLE.
ValidationError(String)
TemplateReload(String)
EndpointUri(EndpointUriError)
Typed endpoint-URI construction error (see EndpointUriError). Promotes the
fail-closed EndpointUri merge failures from stringly-typed errors to a matchable
variant so operators can discriminate programmatically.
UnsupportedMediaType
The request body media type does not match the declared/consumed type (REST DSL default-strict content negotiation, HTTP 415).
NotAcceptable
The response representation cannot satisfy the client’s Accept header (REST DSL default-strict content negotiation, HTTP 406).
ExpressionFailed
Evaluation of a language expression failed during a route step (language-value-boundary spec). All fields are route metadata and typed diagnostics — no exchange data enters any field or the Display output.
Fields
class: ExpressionErrorClassTyped failure classification.
position: Option<ErrorPosition>Position inside the expression source, when the engine reports one.
conversion: Option<ConversionDetail>Failed result-conversion detail, when the failure was a conversion.
cause: Option<Box<CamelError>>Chained underlying error, when the failure wraps another
CamelError (e.g. a catch predicate failure chaining the
original route error).
Implementations§
Source§impl CamelError
impl CamelError
pub fn classify(&self) -> &'static str
Sourcepub fn variant_name(&self) -> &'static str
pub fn variant_name(&self) -> &'static str
Stable variant name used by doTry catch-by-variant matchers.
ProcessorErrorWithSource and AuthProviderUnavailable alias to
"ProcessorError", and EndpointCreationFailedWithSource aliases to
"EndpointCreationFailed" — the aliased variants are not distinguishable
by name in MVP (see spec §5.4), so existing doTry catch handlers keep
matching.
The enum is #[non_exhaustive]; this match lives in the defining crate (camel-api),
so internal exhaustive matching is allowed. Adding a new variant without updating
this method will fail to compile, surfaced by variant_name_tests.
Trait Implementations§
Source§impl Clone for CamelError
Manual Clone impl: every arm clones its fields normally, except
EndpointCreationFailedWithSource, which duplicates the opaque source
handle via the crate-private OpaqueErrorSource::clone_handle (the wrapper
itself is deliberately not Clone). Exhaustive like variant_name() — a
new variant without an arm fails compilation.
impl Clone for CamelError
Manual Clone impl: every arm clones its fields normally, except
EndpointCreationFailedWithSource, which duplicates the opaque source
handle via the crate-private OpaqueErrorSource::clone_handle (the wrapper
itself is deliberately not Clone). Exhaustive like variant_name() — a
new variant without an arm fails compilation.
Source§fn clone(&self) -> CamelError
fn clone(&self) -> CamelError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CamelError
impl Debug for CamelError
Source§impl Display for CamelError
impl Display for CamelError
Source§impl Error for CamelError
impl Error for CamelError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<AuthError> for CamelError
impl From<AuthError> for CamelError
Source§fn from(e: AuthError) -> CamelError
fn from(e: AuthError) -> CamelError
Source§impl From<Box<dyn Error + Send + Sync>> for CamelError
Converts a boxed middleware error into a CamelError.
impl From<Box<dyn Error + Send + Sync>> for CamelError
Converts a boxed middleware error into a CamelError.
A boxed CamelError passes through unchanged. This keeps native exception
matching and fault classification intact after a middleware hop instead of
double-wrapping it as a processor error.
Any other boxed error becomes CamelError::ProcessorErrorWithSource with
the original error preserved as the source, so the chain stays inspectable.
A Tower timeout anywhere in the chain (not only at its root) is reported as
a middleware timeout.
The payload is an OpaqueErrorSource around the Arc, not a bare Arc.
With a bare Arc the chain would skip the pointee: thiserror’s generated
source() delegates through std’s forwarding Error for Arc<T> impl to the
pointee’s own source(). The wrapper instead returns the pointee DIRECTLY
from its own source(), with no Arc hop, so the concrete error is the
FIRST node of the public chain — err.source() already yields it, and
downcast_ref reaches it at hop 1 (e.g.
tower::timeout::error::Elapsed).
§Examples
A boxed CamelError is returned unchanged:
use std::error::Error;
use camel_api::error::CamelError;
let boxed: Box<dyn Error + Send + Sync> = Box::new(CamelError::InvalidUri("u".into()));
match CamelError::from(boxed) {
CamelError::InvalidUri(uri) => assert_eq!(uri, "u"),
other => panic!("expected pass-through, got {other:?}"),
}A timeout nested in the source chain is classified as a middleware timeout, and the source is preserved:
use std::error::Error;
use camel_api::error::CamelError;
use tower::timeout::error::Elapsed;
#[derive(Debug)]
struct TimedOut(Elapsed);
impl std::fmt::Display for TimedOut {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("middleware call timed out")
}
}
impl Error for TimedOut {
fn source(&self) -> Option<&(dyn Error + 'static)> {
Some(&self.0)
}
}
let boxed: Box<dyn Error + Send + Sync> = Box::new(TimedOut(Elapsed::new()));
let err = CamelError::from(boxed);
assert!(err.to_string().contains("middleware timeout elapsed"));
let mut source = err.source();
let mut reached_elapsed = false;
while let Some(inner) = source {
if inner.downcast_ref::<Elapsed>().is_some() {
reached_elapsed = true;
break;
}
source = inner.source();
}
assert!(reached_elapsed, "source chain must reach the original Elapsed");