feat(server): introduce user friendly server errors (#7111)

This commit is contained in:
liuyi
2024-06-17 11:30:58 +08:00
committed by GitHub
parent 5307a55f8a
commit 54fc1197ad
65 changed files with 3170 additions and 924 deletions

View File

@@ -1,4 +1,3 @@
import { BadRequestException } from '@nestjs/common';
import {
Args,
Context,
@@ -11,6 +10,7 @@ import {
Resolver,
} from '@nestjs/graphql';
import { UserNotFound } from '../../fundamentals';
import { sessionUser } from '../auth/service';
import { Admin } from '../common';
import { UserService } from '../user/service';
@@ -59,7 +59,7 @@ export class FeatureManagementResolver {
async removeEarlyAccess(@Args('email') email: string): Promise<number> {
const user = await this.users.findUserByEmail(email);
if (!user) {
throw new BadRequestException(`User ${email} not found`);
throw new UserNotFound();
}
return this.feature.removeEarlyAccess(user.id);
}
@@ -82,7 +82,7 @@ export class FeatureManagementResolver {
const user = await this.users.findUserByEmail(email);
if (!user) {
throw new BadRequestException(`User ${email} not found`);
throw new UserNotFound();
}
await this.feature.addAdmin(user.id);