Skip to content

Chain multiple exception filters execution #3252

@ghost

Description

Feature Request

Is your feature request related to a problem? Please describe.

The issue is that I am not able to execute two exception filters as the filter themselves are actually single pointcut for the chain.

Describe the solution you'd like

The first option would be to have Filter with a similar syntax to Interceptor such that developers can decide if the Filter is a pointcut or not.
A second option would be to apply a Pipe or an Interceptor at different levels, such as to catch errors from Guard.

What is the motivation/use case for changing the behavior?

A request comes into the following API

req -> TraceMiddleware -> AuthGuard -> LoggingInterceptor -> GQLResolver w/ TransformExceptionFilter(HttpException)

Each step can potentially throw an Exception, not necessarely an HttpException.
The Exception transformation is done in a Filter in order to be able to catch errors coming from any step.

As a new feature, I would like to have a logger to log every exception that is happening, potentially with the ExecutionContext from which is thrown, without having to change my existing filter to comply with SRP and prevent mixing up logging with transformation.
Possible scenarios:

  • A Middleware would not have the ExecutionContext.
  • An ExceptionLoggingInterceptor would not be called to log if the failure point is TraceMiddleware or AuthGuard.
  • A second Filter would not be run together with the TransformExceptionFilter.

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