Express Sweet API Reference - v3.0.0
    Preparing search index...

    Class ErrorHandler

    Error handling middleware for Express applications. Catches 404 errors and provides customizable error handling through hooks.

    // Custom error handling in config/config.js
    export default {
    hook_handle_error: (error, req, res, next) => {
    if (error.status === 404)
    res.render('error/404');
    else
    res.render('error/500');
    }
    };
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Mount error handling middleware on Express application. Sets up 404 error catching and custom error handling hooks.

      Parameters

      • app: Express

        Express application instance

      Returns Promise<void>

      // This method is called automatically by express-sweet.mount()
      import ErrorHandler from './middlewares/ErrorHandler';

      await ErrorHandler.mount(app);