feat(server): make permission a standalone module (#7880)

This commit is contained in:
forehalo
2024-08-15 10:01:52 +00:00
parent ba8958f39b
commit 624f3514fc
30 changed files with 123 additions and 116 deletions

View File

@@ -1,4 +1,9 @@
import { ArgumentsHost, Catch, Logger } from '@nestjs/common';
import {
ArgumentsHost,
Catch,
Logger,
NotFoundException,
} from '@nestjs/common';
import { BaseExceptionFilter } from '@nestjs/core';
import { GqlContextType } from '@nestjs/graphql';
import { ThrottlerException } from '@nestjs/throttler';
@@ -9,6 +14,7 @@ import { Socket } from 'socket.io';
import {
InternalServerError,
NotFound,
TooManyRequest,
UserFriendlyError,
} from '../error';
@@ -19,6 +25,8 @@ export function mapAnyError(error: any): UserFriendlyError {
return error;
} else if (error instanceof ThrottlerException) {
return new TooManyRequest();
} else if (error instanceof NotFoundException) {
return new NotFound();
} else {
const e = new InternalServerError();
e.cause = error;