0
0
NestJSframework~5 mins

Built-in HTTP exceptions in NestJS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of built-in HTTP exceptions in NestJS?
Built-in HTTP exceptions in NestJS help you send standard HTTP error responses easily, like 404 Not Found or 400 Bad Request, without writing extra code.
Click to reveal answer
beginner
How do you throw a 404 Not Found error using NestJS built-in exceptions?
You throw a 404 error by using `throw new NotFoundException()` inside your controller or service.
Click to reveal answer
beginner
Name three common built-in HTTP exceptions provided by NestJS.
Three common exceptions are: `BadRequestException` (400), `UnauthorizedException` (401), and `ForbiddenException` (403).
Click to reveal answer
intermediate
What happens when you throw a built-in HTTP exception in a NestJS route handler?
NestJS catches the exception and sends an HTTP response with the correct status code and a JSON message describing the error.
Click to reveal answer
intermediate
Can you customize the error message when throwing a built-in HTTP exception in NestJS?
Yes, you can pass a custom message string or an object as an argument to the exception constructor to customize the error response.
Click to reveal answer
Which NestJS exception should you use to indicate a resource was not found?
ANotFoundException
BBadRequestException
CUnauthorizedException
DForbiddenException
What HTTP status code does BadRequestException correspond to?
A400
B401
C403
D404
How do you send a custom error message with a built-in HTTP exception?
ASet a global variable
BPass the message to the exception constructor
CModify the response object manually
DUse a middleware
Which exception is best for signaling that a user is not allowed to access a resource?
AUnauthorizedException
BBadRequestException
CForbiddenException
DNotFoundException
What does NestJS do when a built-in HTTP exception is thrown?
ARestarts the server
BLogs the error and continues without response
CIgnores the exception
DSends an HTTP response with the correct status and error message
Explain how to use built-in HTTP exceptions in NestJS to handle errors in your application.
Think about how you tell NestJS to send error responses easily.
You got /3 concepts.
    List and describe at least three built-in HTTP exceptions in NestJS and when to use each.
    Focus on common HTTP status codes and their meanings.
    You got /4 concepts.