Complete the code to import the base exception class from NestJS.
import { [1] } from '@nestjs/common';
The HttpException class is the base for creating custom exceptions in NestJS.
Complete the code to define a custom exception class extending the base exception.
export class CustomError extends [1] { constructor(message: string = 'Custom error occurred', status: number = 400) { super(message, status); } }
Custom exceptions extend HttpException to inherit HTTP error behavior.
Fix the error in the constructor to correctly call the base class constructor with message and status.
constructor() {
super([1], 404);
}this.message before calling super.The first argument to super should be the error message string.
Fill both blanks to throw the custom exception with a message and status code.
throw new CustomError([1], [2]);
The custom exception is thrown with a message and a matching HTTP status code.
Fill all three blanks to create a custom exception class with a dynamic message and status code.
export class [1] extends HttpException { constructor(message: string, status: number) { super(message, [2]); this.[3] = message; } }
The class name is DynamicError. The constructor passes status to super. The instance property message is set to the passed message.