getOne(id: number): Movie { const movie = this.movies.find((movie) => movie.id === id); if (!movie) { throw new NotFoundException(`Movie with ID ${id} not found.`); } return movie; }

- NotFoundException : NestJS가 제공하는 예외처리
- HttpException에서 확장된 NestJS의 제공 기능이다.
'Frontend > Nest.js' 카테고리의 다른 글
@InputType과 @ObjectType을 동시에 데코레이터 사용 시 주의할 점 (0) | 2024.06.21 |
---|---|
NestJS : DTO 데이터 전송 객체 (Data Transfer Object) (0) | 2023.01.10 |
NestJS : 형변환 (0) | 2023.01.09 |
NestJS : 라우터 및 데코레이터 설명 (0) | 2023.01.09 |
NestJS : 아키텍처 (0) | 2023.01.09 |