api-err 0.1.0

Convenient to write errors for APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::Category;

pub(crate) fn status_code(category: Option<&Category>) -> u16 {
    let Some(category) = category else {
        return 500;
    };

    match category {
        Category::BadRequest => 400,

        Category::Custom { http_status, .. } => *http_status,
    }
}