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?
✗ Incorrect
NotFoundException sends a 404 HTTP status code, which means the resource was not found.
What HTTP status code does BadRequestException correspond to?
✗ Incorrect
BadRequestException corresponds to HTTP status code 400, indicating a bad client request.
How do you send a custom error message with a built-in HTTP exception?
✗ Incorrect
You pass a custom message string or object to the exception constructor to customize the error message.
Which exception is best for signaling that a user is not allowed to access a resource?
✗ Incorrect
ForbiddenException (403) means the user is authenticated but not allowed to access the resource.
What does NestJS do when a built-in HTTP exception is thrown?
✗ Incorrect
NestJS automatically sends an HTTP response with the proper status code and error message when an exception is thrown.
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.