Enum htrpc::rfc7807::Problem
[−]
[src]
pub enum Problem { AboutBlank(AboutBlankProblem), Trackable(TrackableProblem), }
Problem.
Examples
AboutBlankProblem
:
extern crate htrpc; extern crate serdeconv; use htrpc::rfc7807::Problem; use htrpc::types::HttpStatus; let problem = Problem::about_blank(HttpStatus::NotFound); let http_body = serdeconv::to_json_string_pretty(&problem).unwrap(); assert_eq!(http_body, r#"{ "type": "about:blank", "title": "Not Found", "status": 404 }"#);
TrackableProblem
:
extern crate htrpc; extern crate serdeconv; extern crate trackable; use htrpc::ErrorKind; use htrpc::rfc7807::Problem; use htrpc::types::HttpStatus; use trackable::error::ErrorKindExt; let error = ErrorKind::Other.cause("something wrong"); let problem = Problem::trackable(HttpStatus::NotFound, error); let http_body = serdeconv::to_json_string_pretty(&problem).unwrap(); assert_eq!(http_body, r#"{ "type": "https://docs.rs/htrpc/0.0.2/htrpc/rfc7807/struct.TrackableProblem.html", "title": "An error", "status": 404, "detail": "something wrong", "history": [] }"#);
Variants
AboutBlank(AboutBlankProblem)
type = "about:blank"
.
Trackable(TrackableProblem)
type = "https://docs.rs/htrpc/0.0.2/htrpc/rfc7807/struct.TrackableProblem.html"
.
Methods
impl Problem
[src]
fn about_blank(status: HttpStatus) -> Self
[src]
Makes a new AboutBlankProblem
problem.
fn trackable<E>(status: HttpStatus, error: E) -> Self where
E: Error + Trackable,
E::Event: Display,
[src]
E: Error + Trackable,
E::Event: Display,
Makes a new TrackableProblem
problem.
fn into_response(self) -> ProblemResponse
[src]
Converts into ProblemResponse
.
Trait Implementations
impl Debug for Problem
[src]
impl Default for Problem
[src]
impl From<AboutBlankProblem> for Problem
[src]
fn from(f: AboutBlankProblem) -> Self
[src]
Performs the conversion.
impl From<TrackableProblem> for Problem
[src]
fn from(f: TrackableProblem) -> Self
[src]
Performs the conversion.