Which of the following best explains why structured errors improve API quality?
Think about how clients understand and react to errors.
Structured errors give a clear, consistent format for errors, making it easier for clients to detect and respond to problems.
Given a NestJS API that returns structured errors, what is the expected client behavior?
Structured errors help clients understand what went wrong.
When errors are structured, clients can read error codes and messages to inform users properly or take corrective actions.
Which option correctly throws a structured HTTP error with a custom message and status code in NestJS?
throw new ???('User not found', ???);Use NestJS built-in classes and enums for HTTP errors.
HttpException is the NestJS class for HTTP errors, and HttpStatus.NOT_FOUND is the enum for 404 status.
What error will this NestJS code produce?
throw new HttpException({ message: 'Invalid input' }, 400);Assuming HttpException is imported correctly.
HttpException accepts either string or object as first argument.
HttpException can take an object as the response body, so this code returns a JSON error with message and status 400.
In NestJS, how do structured errors improve the behavior of custom exception filters?
Think about how filters read error information.
Structured errors provide predictable data that filters can use to create uniform error responses and logging.