Skip to content

Commit

Permalink
fix: provide NoSuchNoteError error
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo committed Sep 20, 2023
1 parent 5d65e34 commit fa13b81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/backend/src/core/ClipService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ export class ClipService {
throw new ClipService.NoSuchClipError();
}

const note = await this.notesRepository.findOneBy({ id: noteId });

if (note == null) {
throw new ClipService.NoSuchNoteError();
}

await this.clipNotesRepository.delete({
noteId: noteId,
clipId: clip.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
} catch (e) {
if (e instanceof ClipService.NoSuchClipError) {
throw new ApiError(meta.errors.noSuchClip);
} else if (e instanceof ClipService.NoSuchNoteError) {
throw new ApiError(meta.errors.noSuchNote);
}
throw e;
}
Expand Down

0 comments on commit fa13b81

Please sign in to comment.