[백엔드]error 처리
기본적인 crud를 다 구현하고 Postman으로 테스트할때 만약 에러가 발생했을 시 어떠한 이유때문에 발생한건지예외처리는 필수다. 안그러면 하나하나 로그를 다 찍으면서 계속 서치해야하기 때문이다. 나는 서비스 레이어에서 HttpException라는 커스텀 에러 클래스를 사용해 에러를 던져줬다.async getUser(id: string): Promise { const user = await this._userRepository.findById(id); if (!user) throw new HttpException(404, "해당 유저가 없습니다."); const dtoUser = await new GetUserResponseDTO(user); return dtoUse..
2025.01.10