mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-12-01 13:41:09 -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
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
BadRequestException,
|
|
||||||
CallHandler,
|
CallHandler,
|
||||||
ExecutionContext,
|
ExecutionContext,
|
||||||
Injectable,
|
Injectable,
|
||||||
NestInterceptor,
|
NestInterceptor,
|
||||||
NotFoundException,
|
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { Request } from 'express';
|
import { Request } from 'express';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
import { ForbiddenIdError, NotInDBError } from '../../errors/errors';
|
|
||||||
import { Note } from '../../notes/note.entity';
|
import { Note } from '../../notes/note.entity';
|
||||||
import { NotesService } from '../../notes/notes.service';
|
import { NotesService } from '../../notes/notes.service';
|
||||||
import { User } from '../../users/user.entity';
|
import { User } from '../../users/user.entity';
|
||||||
|
@ -44,17 +41,5 @@ export async function getNote(
|
||||||
noteService: NotesService,
|
noteService: NotesService,
|
||||||
noteIdOrAlias: string,
|
noteIdOrAlias: string,
|
||||||
): Promise<Note> {
|
): Promise<Note> {
|
||||||
let note: Note;
|
return await noteService.getNoteByIdOrAlias(noteIdOrAlias);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue