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

type = "about:blank".

type = "https://docs.rs/htrpc/0.0.2/htrpc/rfc7807/struct.TrackableProblem.html".

Methods

impl Problem
[src]

[src]

Makes a new AboutBlankProblem problem.

[src]

Makes a new TrackableProblem problem.

[src]

Converts into ProblemResponse.

Trait Implementations

impl Debug for Problem
[src]

[src]

Formats the value using the given formatter.

impl Default for Problem
[src]

[src]

Returns the "default value" for a type. Read more

impl From<AboutBlankProblem> for Problem
[src]

[src]

Performs the conversion.

impl From<TrackableProblem> for Problem
[src]

[src]

Performs the conversion.