This crate provides [rocketerrorstack::Report] and [rocketerrorstack::Result] as thin Wrappers around [errorstack::Report] and [errorstack::Result] with rockets [rocket::response::Responder] implemented.
toml
[dependencies]
rocket = { version = "0.5.0-rc.2" }
error-stack = "0.2"
rocket_error_stack = "0.1"
Your Reports will have to implement [rocketerrorstack::StatusCodeReport] to define the HTTP response code.
This crate currently supports rocket 0.5.0-rc.2 and error-stack 0.2.
```rust use std::fmt; use rocket::http::Status; use error_stack::{Context, IntoReport, ResultExt}; use std::fs;
use rocketerrorstack::{Result, StatusCodeReport};
struct SomeError(pub Status);
impl StatusCodeReport for SomeError { fn status(&self) -> Status { self.0 } }
impl fmt::Display for SomeError { fn fmt(&self, f: &mut fmt::Formatter<'>) -> fmt::Result { f.writestr("Error during request") } }
impl Context for SomeError {}
fn get() -> Result<(), SomeError> { fs::readtostring("nonexistent") .intoreport() .attachprintable("Something went wrong!") .change_context(SomeError(Status::InternalServerError))?; Ok(()) }
```