Skip to content

Commit

Permalink
feat: 장소를 찾을 수 없을 때 id 값을 같이 전달할 수도 있게 개선 #52
Browse files Browse the repository at this point in the history
  • Loading branch information
koomchang committed Nov 6, 2024
1 parent 1a2a3ef commit f240aff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions backend/src/place/exception/PlaceNotFoundException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { BaseException } from '../../common/exception/BaseException';
import { HttpStatus } from '@nestjs/common';

export class PlaceNotFoundException extends BaseException {
constructor() {
constructor(id?: number) {
const message = id
? `id:${id} 장소가 존재하지 않습니다.`
: '장소가 존재하지 않습니다.';
super({
code: 1002,
message: '해당 장소가 존재하지 않습니다.',
status: HttpStatus.NO_CONTENT,
message,
status: HttpStatus.NOT_FOUND,
});
}
}
2 changes: 1 addition & 1 deletion backend/src/place/place.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class PlaceService {
async getPlace(id: number) {
const place = await this.placeRepository.findById(id);
if (!place) {
throw new PlaceNotFoundException();
throw new PlaceNotFoundException(id);
}
return place;
}
Expand Down

0 comments on commit f240aff

Please sign in to comment.