Skip to content

error.middleware.ts does not work properly without next parameter #85

@sfernengel

Description

@sfernengel

Currently, the error middleware has the following code:

import { ErrorRequestHandler, Request, Response } from 'express';
import CustomError from '../errors/custom.error';

export const errorMiddleware: ErrorRequestHandler = (
  error: Error,
  _: Request,
  res: Response
) => 

When I run the code with an error, the error middleware does not get called. The signature must conform to what they expect. To make it runnable I suggest the following changes:

```typescript
import { ErrorRequestHandler, NextFunction, Request, Response } from 'express';
import CustomError from '../errors/custom.error';

export const errorMiddleware: ErrorRequestHandler = (
  error: Error,
  _: Request,
  res: Response,
  next: NextFunction
) => {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions