Skip to main content

ExceptionFilter

Trait ExceptionFilter 

Source
pub trait ExceptionFilter:
    Send
    + Sync
    + 'static {
    // Required method
    fn catch(
        &self,
        exception: HttpException,
        ctx: &RequestContext,
    ) -> HttpException;
}
Expand description

This is the crate users will import. It re-exports the internal pieces use nestforge::{NestForgeFactory, ModuleDefinition, Container}; A filter that catches exceptions thrown during request processing.

Use this to transform HttpExceptions into different responses or to log errors.

§Example

struct LoggingFilter;
impl ExceptionFilter for LoggingFilter {
    fn catch(&self, exception: HttpException, ctx: &RequestContext) -> HttpException {
        println!("Error: {:?}", exception);
        exception
    }
}

Required Methods§

Source

fn catch(&self, exception: HttpException, ctx: &RequestContext) -> HttpException

Implementors§