The exception filter must implement the ExceptionFilter interface, and the @Catch(HttpException) decorator will bind the necessary data to the exception filter.
If HttpStatus is 500 or higher, set E001 in constants.ts as internal server error, otherwise set thrown exception.message.
If you want to return E002 as an authentication error, set the error code to UnauthorisedException and throw it.
throw new UnauthorizedException(ErrorCode.E002);
Commonisation of Responses
For a common Response, see this article.
あわせて読みたい
【NestJS】How to convert Response.NestJS is an efficient and scalable Node.js application.It also provides a generate command, which allows you to create an API simply and easily. In this cas...