From 3aeda955d99b9e3ade02af8b77b9d4690ba6df4b Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Thu, 25 Feb 2021 13:59:32 +0100 Subject: [PATCH] MediaController: Handle MediaBackendErrors Signed-off-by: Philip Molares --- src/api/public/media/media.controller.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/api/public/media/media.controller.ts b/src/api/public/media/media.controller.ts index 436e87b4c..4520e6b91 100644 --- a/src/api/public/media/media.controller.ts +++ b/src/api/public/media/media.controller.ts @@ -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; } }