improve error handling

This commit is contained in:
syuilo
2023-02-12 10:36:43 +09:00
parent 9ddf62d8b7
commit b55d26387b
2 changed files with 18 additions and 3 deletions

View File

@@ -14,6 +14,8 @@ import { RoleService } from '@/core/RoleService.js';
@Injectable()
export class UserListService {
public static TooManyUsersError = class extends Error {};
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
@@ -36,7 +38,7 @@ export class UserListService {
userListId: list.id,
});
if (currentCount > (await this.roleService.getUserPolicies(me.id)).userEachUserListsLimit) {
throw new Error('Too many users');
throw new UserListService.TooManyUsersError();
}
await this.userListJoiningsRepository.insert({