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