mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-29 06:04:28 -05:00
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:
parent
4ad7ad368c
commit
d0477a5e34
1 changed files with 1 additions and 16 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue