From adc9ca69395869f0294d7de1fd8df9231e515bb0 Mon Sep 17 00:00:00 2001 From: David Mehren Date: Sun, 29 Aug 2021 17:32:45 +0200 Subject: [PATCH] Public API: Remove superfluous try/catch `getNoteMetadata` does not use a method that can throw a `PermissionsUpdateInconsistentError`. The try/catch-block seems to be a copy-paste error. Signed-off-by: David Mehren --- src/api/public/notes/notes.controller.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/api/public/notes/notes.controller.ts b/src/api/public/notes/notes.controller.ts index 923ecd15b..ecb2c65b7 100644 --- a/src/api/public/notes/notes.controller.ts +++ b/src/api/public/notes/notes.controller.ts @@ -226,17 +226,10 @@ export class NotesController { @RequestUser() user: User, @Param('noteIdOrAlias', GetNotePipe) note: Note, ): Promise { - try { - if (!this.permissionsService.mayRead(user, note)) { - throw new UnauthorizedException('Reading note denied!'); - } - return await this.noteService.toNoteMetadataDto(note); - } catch (e) { - if (e instanceof PermissionsUpdateInconsistentError) { - throw new BadRequestException(e.message); - } - throw e; + if (!this.permissionsService.mayRead(user, note)) { + throw new UnauthorizedException('Reading note denied!'); } + return await this.noteService.toNoteMetadataDto(note); } @UseGuards(TokenAuthGuard)