basic_usage/basic_usage.rs
1use problem_details_mapper::ProblemDetailsMapper;
2
3fn main() {
4 // Setup the mapper settings
5 ProblemDetailsMapper::setup(|options| {
6 // will map every error given to a http status code 500.
7 options.map_std_err();
8 }).unwrap();
9
10 // Map an error to a Problem Details response
11 let error = std::io::Error::new(std::io::ErrorKind::NotFound, "File not found");
12 let problem_details = ProblemDetailsMapper::map(Box::new(error));
13
14 // Output the Problem Details response
15 println!("{:?}", problem_details);
16}