messua/errs
A collection of convenience functions for creating Errs in
multiple ways.
Several of these just have mnemonic names in case that’s easier for you, or clearer to future you, than remembering specific HTTP status codes.
Functions
pub fn bad_request() -> Err
Error 400: Bad Request
The request is missing some information, like a header value or a well-formed body that the server needs to respond to it.
pub fn content_too_large() -> Err
Error 413: Content Too Large
For when the client has sent a larger request body than the server would like.
pub fn error() -> Err
Error 500: Internal Server Error
The generic catch-all error to send when the server has encountered a problem.
pub fn forbidden() -> Err
Error 403: Forbidden
The server knows who the client is, it just won’t let them do what they’re asking.
pub fn method_not_allowed() -> Err
Error 405: Method Not Allowed
It’s considered good practice to inclued an Allow header in the
response listing the methods you do allow.
pub fn not_found() -> Err
Error 404: Not Found
This one has become a meme that even nontechnical people use.
pub fn not_implemented() -> Err
Error 501: Not Implemented
This is a good thing to return when you haven’t finished building your service.
pub fn teapot() -> Err
Error 418: I’m a Teapot
It’s probably acceptable to return this response for any request that just seems wildly out of order.
pub fn too_many_requests() -> Err
Error 429: Too Many Requests
The server has decided to rate limit the client.
pub fn unauthorized() -> Err
Error 401: Unauthorized
The client hasn’t convinced the server they are who they say they are.