Skip to main content

CamelError

Enum CamelError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§method: String
§status_code: u16
§status_text: String
§response_body: Option<String>
§

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)

§

Unauthorized(String)

§

AuthProviderUnavailable(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).

Fields

§consumed: String
§declared: String
§

NotAcceptable

The response representation cannot satisfy the client’s Accept header (REST DSL default-strict content negotiation, HTTP 406).

Fields

§accept: String
§produced: String
§

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

§language: String

Language the failing expression was written in (e.g. rhai).

§route_id: String

Id of the route that owned the failing step.

§step_id: String

Id of the failing step.

§verb: String

DSL verb that evaluated the expression (e.g. set_property).

§class: ExpressionErrorClass

Typed 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

Source

pub fn classify(&self) -> &'static str

Source

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.

Source§

fn clone(&self) -> CamelError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CamelError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for CamelError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Error for CamelError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<AuthError> for CamelError

Source§

fn from(e: AuthError) -> CamelError

Converts to this type from the input type.
Source§

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");
Source§

fn from(err: Box<dyn Error + Send + Sync>) -> CamelError

Converts to this type from the input type.
Source§

impl From<ConfigValidationError> for CamelError

Source§

fn from(e: ConfigValidationError) -> CamelError

Converts to this type from the input type.
Source§

impl From<EndpointUriError> for CamelError

Source§

fn from(e: EndpointUriError) -> CamelError

Converts to this type from the input type.
Source§

impl From<Error> for CamelError

Source§

fn from(err: Error) -> CamelError

Converts to this type from the input type.
Source§

impl From<TemplateError> for CamelError

Source§

fn from(err: TemplateError) -> CamelError

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more