feat: add ErrorExceptionMapping as a global filter

This filters all error that the controller will throw and either maps
them to the correct HttpException if they are internal errors like
NotInDBError, or just leaves them be if they are not part in the map.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-01-23 22:45:53 +01:00
parent 2c7e82680e
commit 2cd4f412e5

View file

@ -12,6 +12,7 @@ import { AppModule } from './app.module';
import { AppConfig } from './config/app.config';
import { AuthConfig } from './config/auth.config';
import { MediaConfig } from './config/media.config';
import { ErrorExceptionMapping } from './errors/error-mapping';
import { ConsoleLoggerService } from './logger/console-logger.service';
import { BackendType } from './media/backends/backend-type.enum';
import { setupSpecialGroups } from './utils/createSpecialGroups';
@ -78,6 +79,7 @@ async function bootstrap(): Promise<void> {
app.useStaticAssets('public', {
prefix: '/public/',
});
app.useGlobalFilters(new ErrorExceptionMapping());
await app.listen(appConfig.port);
logger.log(`Listening on port ${appConfig.port}`, 'AppBootstrap');
}