Skip to content

Cover error handling of Middleware in documentation #215

Open
@l0rn

Description

@l0rn

I'd like to file a:

[ X ] Documentation issue or request

Nowhere in Nest v5 docs is an example to be found how to handle errors originating from middleware. Neither in the Exception Filter section nor in the Middleware section.

I also tried to put my Filter on the Middleware itself - doesn't get executed either:

import { CsurfMiddleware as NestCsurfMiddleware } from '@nest-middlewares/csurf';
import { UseFilters, Injectable } from '@nestjs/common';
import { CSRFExceptionFilter } from './csrf-exception.filter';

@UseFilters(
    new CSRFExceptionFilter(),
)
@Injectable()
export class CsurfMiddleware extends NestCsurfMiddleware {}

This guy seems to have the same question but it's left unanswered: nestjs/nest#294

I would argue this is a rather common use case as Middleware is based on express middleware in many cases throwing all kinds of typescript unfriendly errors you might want to catch / transform.

So a concrete documentation requests would be:

  • How / where to handle errors coming from middleware

I'd be happy to contribute it myself, but I couldn't figure out how to do it until now. So if someone points me to the right direction i will write it up for the docs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions