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 <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-01-17 09:08:50 +01:00
parent 4ad7ad368c
commit d0477a5e34

View file

@ -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<Note> {
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);
}