Bird
0
0

You want to customize the error message returned by JwtAuthGuard when token validation fails. Which method should you override in your guard class?

hard📝 Application Q8 of 15
NestJS - Guards
You want to customize the error message returned by JwtAuthGuard when token validation fails. Which method should you override in your guard class?
AvalidateToken
BcanActivate
ChandleRequest
DgetTokenFromRequest
Step-by-Step Solution
Solution:
  1. Step 1: Understand JwtAuthGuard customization points

    handleRequest method allows customizing error handling after validation.
  2. Step 2: Confirm method to override

    Overriding handleRequest lets you change error messages or behavior on failure.
  3. Final Answer:

    handleRequest -> Option C
  4. Quick Check:

    Customize errors by overriding handleRequest [OK]
Quick Trick: Override handleRequest to customize guard errors [OK]
Common Mistakes:
  • Trying to override canActivate for error messages
  • Assuming validateToken is a guard method
  • Thinking getTokenFromRequest controls errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes