diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-09-20 11:29:10 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-09-20 11:29:10 +0900 |
| commit | c3db55b5b6c3bc35ca1bdd6b412da7f0d47b58cc (patch) | |
| tree | 696745f5ab557b08985429dbcec2cd9c64879669 /packages/backend | |
| parent | feat(frontend): スリープ無効化機能 (diff) | |
| download | sharkey-c3db55b5b6c3bc35ca1bdd6b412da7f0d47b58cc.tar.gz sharkey-c3db55b5b6c3bc35ca1bdd6b412da7f0d47b58cc.tar.bz2 sharkey-c3db55b5b6c3bc35ca1bdd6b412da7f0d47b58cc.zip | |
fix
Diffstat (limited to 'packages/backend')
| -rw-r--r-- | packages/backend/src/core/ClipService.ts | 7 | ||||
| -rw-r--r-- | packages/backend/src/server/api/endpoints/clips/add-note.ts | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/packages/backend/src/core/ClipService.ts b/packages/backend/src/core/ClipService.ts index 59f213c00c..27f3013d4a 100644 --- a/packages/backend/src/core/ClipService.ts +++ b/packages/backend/src/core/ClipService.ts @@ -15,6 +15,7 @@ import type { MiLocalUser } from '@/models/entities/User.js'; @Injectable() export class ClipService { + public static NoSuchNoteError = class extends Error {}; public static NoSuchClipError = class extends Error {}; public static AlreadyAddedError = class extends Error {}; public static TooManyClipNotesError = class extends Error {}; @@ -118,10 +119,14 @@ export class ClipService { noteId: noteId, clipId: clip.id, }); - } catch (e) { + } catch (e: any) { if (isDuplicateKeyValueError(e)) { throw new ClipService.AlreadyAddedError(); + } else if (e.detail.includes('is not present in table "note".')) { + throw new ClipService.NoSuchNoteError(); } + + throw e; } this.clipsRepository.update(clip.id, { diff --git a/packages/backend/src/server/api/endpoints/clips/add-note.ts b/packages/backend/src/server/api/endpoints/clips/add-note.ts index a3777e3ba6..749593aa65 100644 --- a/packages/backend/src/server/api/endpoints/clips/add-note.ts +++ b/packages/backend/src/server/api/endpoints/clips/add-note.ts @@ -70,6 +70,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); } else if (e instanceof ClipService.AlreadyAddedError) { throw new ApiError(meta.errors.alreadyClipped); } else if (e instanceof ClipService.TooManyClipNotesError) { |