Bird
0
0

What will be the result if you apply @UseGuards(AuthGuard, RolesGuard) but AuthGuard throws an exception?

medium📝 component behavior Q5 of 15
NestJS - Guards

What will be the result if you apply @UseGuards(AuthGuard, RolesGuard) but AuthGuard throws an exception?

ABoth guards run and their results are combined
BRolesGuard runs anyway and decides access
CThe exception is ignored and access is granted
DThe exception is propagated and the request is terminated
Step-by-Step Solution
Solution:
  1. Step 1: Understand guard execution order

    Guards run in order; if one throws an exception, execution stops.
  2. Step 2: Analyze exception behavior

    AuthGuard throwing an exception stops further guards and terminates the request with error.
  3. Final Answer:

    The exception is propagated and the request is terminated -> Option D
  4. Quick Check:

    Exception in guard stops request [OK]
Quick Trick: Exception in any guard stops all further checks [OK]
Common Mistakes:
  • Assuming all guards run despite exceptions
  • Thinking exceptions are ignored
  • Believing access is granted on exception

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes