Skip to content

Commit

Permalink
refactor: getDiaryByUuid 원상복구
Browse files Browse the repository at this point in the history
- getDiaryByUuid에서 직접 에러를 throw하도록 원상복구
  • Loading branch information
JoonSoo-Kim committed Nov 22, 2023
1 parent 351867c commit e6a9164
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 5 additions & 4 deletions BE/src/diaries/diaries.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ export class DiariesRepository {
async deleteDiary(deleteDiaryDto: DeleteDiaryDto): Promise<void> {
const { uuid } = deleteDiaryDto;
const diary = await this.getDiaryByUuid(uuid);
if (!diary) {
throw new Error();
}

await Diary.softRemove(diary);
}

async getDiaryByUuid(uuid: string): Promise<Diary> {
return Diary.findOneBy({ uuid });
const found = await Diary.findOneBy({ uuid });
if (!found) {
throw new NotFoundException(`존재하지 않는 일기입니다.`);
}
return found;
}
}
6 changes: 1 addition & 5 deletions BE/src/diaries/diaries.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ export class DiariesService {
}

async deleteDiary(deleteDiaryDto: DeleteDiaryDto): Promise<void> {
try {
await this.diariesRepository.deleteDiary(deleteDiaryDto);
} catch {
throw new NotFoundException("존재하지 않는 일기입니다.");
}
await this.diariesRepository.deleteDiary(deleteDiaryDto);
return;
}
}

0 comments on commit e6a9164

Please sign in to comment.