pub enum ApiError {
BadRequest(String),
PayloadTooLarge(String),
NotFound(String),
Timeout(&'static str),
Internal(String),
}Expand description
Errors produced by API handlers, each carrying the HTTP status code Firecracker returns for that class of failure.
Status codes match upstream where they exist (200 / 204 / 400 / 413 / 500). 504 is squib-only and surfaces the per-action-class timeout taxonomy from 70-security.md § 6.
Variants§
BadRequest(String)
Generic 400 error with a custom fault message — the bulk of validation / state-machine / parse failures land here.
PayloadTooLarge(String)
413 Payload Too Large — used by the body-size limit middleware and by MMDS
endpoints when the data store would exceed --mmds-size-limit.
NotFound(String)
404 Not Found — the path does not match any registered route. We translate this to a 400 in the response (axum’s default 404 is overridden); Firecracker has no 404 in its surface.
Timeout(&'static str)
504 Gateway Timeout — squib-only. Emitted when a per-action-class timeout fires
while the controller awaits the VMM. The action remains pending at the VMM
(cancelling it would leave undefined state); the controller logs at error.
&'static str because the action class name is always known at the call site.
Internal(String)
500 Internal Server Error — used when the VMM event loop has shut down and a
handler can no longer dispatch. Rare; logged at error.
Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Status code this error variant maps to.
Sourcepub fn fault_message(&self) -> String
pub fn fault_message(&self) -> String
The exact fault_message body string this error surfaces.
Trait Implementations§
Source§impl Error for ApiError
impl Error for ApiError
1.30.0 · 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()