아카이브/미륵관심법
Exception Filters
verdantjuly
2023. 10. 14. 10:37
728x90
1. exceptionHandler.ts를 만든다.
// exceptionHandler.ts
import { HttpException } from "@nestjs/common";
import { HttpStatus } from "@nestjs/common";
export class InternalServerErrorException extends HttpException {
constructor() {
super("일시적인 오류가 발생했습니다.", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
2. catch 된 에러가 있다면 throw를 발생시킨다.
catch (error) {
throw new InternalServerErrorException();
}
결과