MediaController: Handle MediaBackendErrors

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2021-02-25 13:59:32 +01:00
parent 8365132a39
commit 31f7c76697

View file

@ -9,6 +9,7 @@ import {
Controller,
Delete,
Headers,
InternalServerErrorException,
NotFoundException,
Param,
Post,
@ -21,6 +22,7 @@ import {
import { FileInterceptor } from '@nestjs/platform-express';
import {
ClientError,
MediaBackendError,
NotInDBError,
PermissionError,
} from '../../../errors/errors';
@ -66,6 +68,11 @@ export class MediaController {
if (e instanceof ClientError || e instanceof NotInDBError) {
throw new BadRequestException(e.message);
}
if (e instanceof MediaBackendError) {
throw new InternalServerErrorException(
'There was an error in the media backend',
);
}
throw e;
}
}
@ -86,6 +93,11 @@ export class MediaController {
if (e instanceof NotInDBError) {
throw new NotFoundException(e.message);
}
if (e instanceof MediaBackendError) {
throw new InternalServerErrorException(
'There was an error in the media backend',
);
}
throw e;
}
}