diff --git a/src/notes/notes.service.spec.ts b/src/notes/notes.service.spec.ts index 228e0f9fb..b1819f4d0 100644 --- a/src/notes/notes.service.spec.ts +++ b/src/notes/notes.service.spec.ts @@ -321,7 +321,7 @@ describe('NotesService', () => { it('id is forbidden', async () => { await expect( service.getNoteByIdOrAlias(forbiddenNoteId), - ).rejects.toThrow(ForbiddenIdError); + ).rejects.toThrow(NotInDBError); }); }); }); diff --git a/src/notes/notes.service.ts b/src/notes/notes.service.ts index 99c33904b..484c7ce89 100644 --- a/src/notes/notes.service.ts +++ b/src/notes/notes.service.ts @@ -156,7 +156,6 @@ export class NotesService { * Get a note by either their id or alias. * @param {string} noteIdOrAlias - the notes id or alias * @return {Note} the note - * @throws {ForbiddenIdError} the requested id or alias is forbidden * @throws {NotInDBError} there is no note with this id or alias */ async getNoteByIdOrAlias(noteIdOrAlias: string): Promise { @@ -164,7 +163,14 @@ export class NotesService { `Trying to find note '${noteIdOrAlias}'`, 'getNoteByIdOrAlias', ); - this.checkNoteIdOrAlias(noteIdOrAlias); + try { + this.checkNoteIdOrAlias(noteIdOrAlias); + } catch (e) { + if (e instanceof ForbiddenIdError) { + throw new NotInDBError(e.message); + } + throw e; + } /** * This query gets the note's aliases, owner, groupPermissions (and the groups), userPermissions (and the users) and tags and