Skip to main content

haste_server/
error.rs

1//! Server-wide failures that wrap a foreign error. A `#[from]` field keeps
2//! that error as the source, so `map_err(ServerError::from)` is all a call
3//! site needs and the log still shows what went wrong.
4
5use haste_fhir_operation_error::derive::OperationOutcomeError;
6
7#[derive(OperationOutcomeError, Debug)]
8pub enum ServerError {
9    /// A response or stored value the server built did not serialize.
10    #[fatal(code = "exception", diagnostic = "Failed to serialize the response.")]
11    Serialize(#[from] serde_json::Error),
12    /// The configured API URL does not parse, or a path cannot be joined to it.
13    #[fatal(code = "exception", diagnostic = "Invalid API URL configured.")]
14    InvalidApiUrl(#[from] url::ParseError),
15    /// The configured API URL is not a valid `http::Uri` either.
16    #[fatal(code = "exception", diagnostic = "Invalid API URL configured.")]
17    InvalidApiUri(#[from] axum::http::uri::InvalidUri),
18}