03 / 03

How does exception filter precedence work when multiple filters are registered in NestJS?

Unlike guards and interceptors (global → controller → method), exception filter resolution works in reverse: method → controller → global. The most specific filter wins. The @Catch() type must match the thrown exception for a filter to apply — a filter for NotFoundException will not handle BadRequestException.

Filter precedence with multiple registered filters
Filter resolution rules:
  1. 1

    Method-level filters are checked first, then controller-level, then global.

  2. 2

    The first filter whose @Catch() type matches the thrown exception handles it.

  3. 3

    @Catch(NotFoundException) will NOT handle BadRequestException — the types must match.

  4. 4

    @Catch() with no argument matches everything — use only at the global level.

  5. 5

    Multiple @Catch() types are supported: @Catch(NotFoundException, BadRequestException).