fix: provide NoSuchNoteError error
This commit is contained in:
parent
5d65e34078
commit
fa13b815ef
|
@ -143,6 +143,12 @@ export class ClipService {
|
||||||
throw new ClipService.NoSuchClipError();
|
throw new ClipService.NoSuchClipError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const note = await this.notesRepository.findOneBy({ id: noteId });
|
||||||
|
|
||||||
|
if (note == null) {
|
||||||
|
throw new ClipService.NoSuchNoteError();
|
||||||
|
}
|
||||||
|
|
||||||
await this.clipNotesRepository.delete({
|
await this.clipNotesRepository.delete({
|
||||||
noteId: noteId,
|
noteId: noteId,
|
||||||
clipId: clip.id,
|
clipId: clip.id,
|
||||||
|
|
|
@ -52,6 +52,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof ClipService.NoSuchClipError) {
|
if (e instanceof ClipService.NoSuchClipError) {
|
||||||
throw new ApiError(meta.errors.noSuchClip);
|
throw new ApiError(meta.errors.noSuchClip);
|
||||||
|
} else if (e instanceof ClipService.NoSuchNoteError) {
|
||||||
|
throw new ApiError(meta.errors.noSuchNote);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue