From d0477a5e3430c57a1c44ae2c92d318c423e0c093 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Mon, 17 Jan 2022 09:08:50 +0100 Subject: [PATCH] refactor: omit error mapping in GetNoteInterceptor Because this mapping will now be done with the ErrorExceptionMapping class, the mapping will be omitted in the interceptor. Signed-off-by: Philip Molares --- src/api/utils/get-note.interceptor.ts | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/api/utils/get-note.interceptor.ts b/src/api/utils/get-note.interceptor.ts index 80d98aa13..3dd9d8838 100644 --- a/src/api/utils/get-note.interceptor.ts +++ b/src/api/utils/get-note.interceptor.ts @@ -4,17 +4,14 @@ * SPDX-License-Identifier: AGPL-3.0-only */ import { - BadRequestException, CallHandler, ExecutionContext, Injectable, NestInterceptor, - NotFoundException, } from '@nestjs/common'; import { Request } from 'express'; import { Observable } from 'rxjs'; -import { ForbiddenIdError, NotInDBError } from '../../errors/errors'; import { Note } from '../../notes/note.entity'; import { NotesService } from '../../notes/notes.service'; import { User } from '../../users/user.entity'; @@ -44,17 +41,5 @@ export async function getNote( noteService: NotesService, noteIdOrAlias: string, ): Promise { - let note: Note; - try { - note = await noteService.getNoteByIdOrAlias(noteIdOrAlias); - } catch (e) { - if (e instanceof NotInDBError) { - throw new NotFoundException(e.message); - } - if (e instanceof ForbiddenIdError) { - throw new BadRequestException(e.message); - } - throw e; - } - return note; + return await noteService.getNoteByIdOrAlias(noteIdOrAlias); }