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
+3 -2
View File
@@ -16,6 +16,7 @@
*/
import * as Sequelize from 'sequelize'
import { ValidationException } from '../exception'
import { MinuteOfDay } from '../util/minuteofday'
import { familyIdColumn, idWithinFamilyColumn, timestampColumn } from './columns'
import { SequelizeAttributes } from './types'
@@ -85,11 +86,11 @@ export const attributesVersion1: SequelizeAttributes<SessionDurationAttributesVe
const startMinuteOfDay = this.startMinuteOfDay
if (typeof endMinuteOfDay !== 'number' || typeof startMinuteOfDay !== 'number') {
throw new Error('wrong data types')
throw new ValidationException({ staticMessage: 'wrong data types for start and end minute at the session duration' })
}
if (startMinuteOfDay > endMinuteOfDay) {
throw new Error('startMinuteOfDay must not be bigger than endMinuteOfDay')
throw new ValidationException({ staticMessage: 'startMinuteOfDay must not be bigger than endMinuteOfDay for a session duration' })
}
}
}
+3 -2
View File
@@ -16,6 +16,7 @@
*/
import * as Sequelize from 'sequelize'
import { ValidationException } from '../exception'
import { MinuteOfDay } from '../util/minuteofday'
import { booleanColumn, familyIdColumn, idWithinFamilyColumn } from './columns'
import { SequelizeAttributes } from './types'
@@ -90,11 +91,11 @@ export const attributesVersion2: SequelizeAttributes<TimelimitRuleAttributesVers
const startMinuteOfDay = this.startMinuteOfDay
if (typeof endMinuteOfDay !== 'number' || typeof startMinuteOfDay !== 'number') {
throw new Error('wrong data types')
throw new ValidationException({ staticMessage: 'wrong data types for start and end minute at the time limit rule' })
}
if (startMinuteOfDay > endMinuteOfDay) {
throw new Error('startMinuteOfDay must not be bigger than endMinuteOfDay')
throw new ValidationException({ staticMessage: 'startMinuteOfDay must not be bigger than endMinuteOfDay for a time limit rule' })
}
}
},
+3 -2
View File
@@ -16,6 +16,7 @@
*/
import * as Sequelize from 'sequelize'
import { ValidationException } from '../exception'
import { MinuteOfDay } from '../util/minuteofday'
import { familyIdColumn, idWithinFamilyColumn, timestampColumn } from './columns'
import { SequelizeAttributes } from './types'
@@ -100,11 +101,11 @@ export const attributesVersion3: SequelizeAttributes<UsedTimeAttributesVersion3>
const startMinuteOfDay = this.startMinuteOfDay
if (typeof endMinuteOfDay !== 'number' || typeof startMinuteOfDay !== 'number') {
throw new Error('wrong data types')
throw new ValidationException({ staticMessage: 'wrong data types for start and end minute at the used time' })
}
if (startMinuteOfDay > endMinuteOfDay) {
throw new Error('startMinuteOfDay must not be bigger than endMinuteOfDay')
throw new ValidationException({ staticMessage: 'startMinuteOfDay must not be bigger than endMinuteOfDay for a used time' })
}
}
}