Skip to main content

build_problem_response

Function build_problem_response 

Source
pub fn build_problem_response(
    error: &LinoHttpError,
    media_type: &str,
    instance: Option<&str>,
) -> ResponseParts
Expand description

Render an error as problem details (specification section 5).

ยงExamples

use lino_rest_api::middleware::build_problem_response;
use lino_rest_api::problem::LinoHttpError;

let parts = build_problem_response(
    &LinoHttpError::new(404, Some("No task 7")),
    "text/lino",
    Some("/tasks/7"),
);
assert_eq!(parts.status, 404);
assert_eq!(
    parts.headers.get("content-type"),
    Some("application/problem+lino; charset=utf-8"),
);