HttpErrorHandler

Trait HttpErrorHandler 

Source
pub trait HttpErrorHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn error(&self, req: &HttpRequest, error: &dyn HttpError) -> HttpResponse;
    fn plain_code(&self, code: StatusCode) -> HttpResponse;
}
Expand description

Handler for possible service errors

Returned status code (res.code) is not used, it is overriden by original status code. This is made to avoid returning 200 Ok errors

If you want to change the code, consider altering the HttpError implementation

Required Methods§

Source

fn error(&self, req: &HttpRequest, error: &dyn HttpError) -> HttpResponse

Constructs an HttpResponse from given HttpError

Source

fn plain_code(&self, code: StatusCode) -> HttpResponse

Shows a plain error code page for internal errors

Implementors§