improve error handling
This commit is contained in:
parent
9ddf62d8b7
commit
b55d26387b
2 changed files with 18 additions and 3 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue