64 lines
2.4 KiB
Rust
64 lines
2.4 KiB
Rust
use serde_json::Value;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum ExternalReferenceFetchError {
|
|
#[error("external references are disabled")]
|
|
Disabled,
|
|
#[error("external reference URL is invalid")]
|
|
InvalidUrl,
|
|
#[error("external reference target is not allowed")]
|
|
TargetNotAllowed,
|
|
#[error("external reference redirects are not allowed")]
|
|
RedirectNotAllowed,
|
|
#[error("external reference response exceeds the configured limit of {limit_bytes} bytes")]
|
|
ResponseTooLarge { limit_bytes: usize },
|
|
#[error("external reference endpoint returned status {status}")]
|
|
UnexpectedStatus { status: u16 },
|
|
#[error("external reference request failed")]
|
|
Transport { timeout: bool, connect: bool },
|
|
#[error("external reference fetch configuration is invalid")]
|
|
InvalidConfiguration,
|
|
}
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum RestAdapterError {
|
|
#[error("invalid base url: {url}")]
|
|
InvalidBaseUrl { url: String },
|
|
#[error("invalid path parameter {key}")]
|
|
InvalidPathParameter { key: String },
|
|
#[error("invalid query parameter {key}")]
|
|
InvalidQueryParameter { key: String },
|
|
#[error("invalid header name {header}")]
|
|
InvalidHeaderName { header: String },
|
|
#[error("invalid header value for {header}")]
|
|
InvalidHeaderValue { header: String },
|
|
#[error("outbound target is not allowed")]
|
|
TargetNotAllowed { target: String },
|
|
#[error("outbound redirects are not allowed")]
|
|
RedirectNotAllowed,
|
|
#[error("rest request exceeds the configured limit of {limit_bytes} bytes")]
|
|
RequestTooLarge { limit_bytes: usize },
|
|
#[error("rest response exceeds the configured limit of {limit_bytes} bytes")]
|
|
ResponseTooLarge { limit_bytes: usize },
|
|
#[error("invalid outbound HTTP configuration: {details}")]
|
|
InvalidConfiguration { details: String },
|
|
#[error("request failed")]
|
|
Transport { timeout: bool, connect: bool },
|
|
#[error("sse collection window expired before stream completed")]
|
|
WindowExpired,
|
|
#[error("rest endpoint returned status {status}")]
|
|
UnexpectedStatus { status: u16, body: Value },
|
|
#[error("sse stream produced malformed event payload")]
|
|
InvalidSseEvent,
|
|
}
|
|
|
|
impl From<reqwest::Error> for RestAdapterError {
|
|
fn from(value: reqwest::Error) -> Self {
|
|
Self::Transport {
|
|
timeout: value.is_timeout(),
|
|
connect: value.is_connect(),
|
|
}
|
|
}
|
|
}
|