mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Refactor exception usage
This commit is contained in:
@@ -62,6 +62,8 @@ import {
|
||||
UpdateUserLimitLoginCategory
|
||||
} from '../../../../action'
|
||||
import { Cache } from '../cache'
|
||||
import { ActionObjectTypeNotHandledException } from '../exception/illegal-state'
|
||||
import { ActionNotSupportedBySelfLimitationException } from '../exception/self-limit'
|
||||
import { dispatchAddCategoryApps } from './addcategoryapps'
|
||||
import { dispatchAddCategoryNetworkId } from './addcategorynetworkid'
|
||||
import { dispatchAddUser } from './adduser'
|
||||
@@ -129,7 +131,9 @@ export const dispatchParentAction = async ({ action, cache, parentUserId, source
|
||||
return dispatchUpdateCategoryBlockedTimes({ action, cache, fromChildSelfLimitAddChildUserId })
|
||||
}
|
||||
|
||||
if (fromChildSelfLimitAddChildUserId === null) {
|
||||
if (fromChildSelfLimitAddChildUserId !== null) {
|
||||
throw new ActionNotSupportedBySelfLimitationException()
|
||||
} else {
|
||||
if (action instanceof AddCategoryNetworkIdAction) {
|
||||
return dispatchAddCategoryNetworkId({ action, cache })
|
||||
} else if (action instanceof AddUserAction) {
|
||||
@@ -202,8 +206,8 @@ export const dispatchParentAction = async ({ action, cache, parentUserId, source
|
||||
return dispatchUpdateUserFlagsAction({ action, cache })
|
||||
} else if (action instanceof UpdateUserLimitLoginCategory) {
|
||||
return dispatchUpdateUserLimitLoginCategoryAction({ action, cache, parentUserId })
|
||||
} else {
|
||||
throw new ActionObjectTypeNotHandledException()
|
||||
}
|
||||
} else {
|
||||
throw new Error('unsupported action type')
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user