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 committed by David Mehren
parent 8e7be737fa
commit 3aeda955d9
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

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;
}
}