Refactor exception usage

This commit is contained in:
Jonas Lochmann
2020-09-28 02:00:00 +02:00
parent d68b425e0e
commit 8d65c5d777
148 changed files with 2061 additions and 769 deletions
+6 -3
View File
@@ -16,8 +16,10 @@
*/
import { allowedTimeWarningFlags } from '../database/category'
import { assertIdWithinFamily } from '../util/token'
import { ParentAction } from './basetypes'
import { assertIdWithinFamily, assertSafeInteger, throwOutOfRange } from './meta/util'
const actionType = 'UpdateCategoryTimeWarningsAction'
export class UpdateCategoryTimeWarningsAction extends ParentAction {
readonly categoryId: string
@@ -31,10 +33,11 @@ export class UpdateCategoryTimeWarningsAction extends ParentAction {
}) {
super()
assertIdWithinFamily(categoryId)
assertIdWithinFamily({ actionType, field: 'categoryId', value: categoryId })
assertSafeInteger({ actionType, field: 'flags', value: flags })
if ((flags & allowedTimeWarningFlags) !== flags) {
throw new Error('illegal flags')
throwOutOfRange({ actionType, field: 'flags', value: flags })
}
this.categoryId = categoryId