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
+4 -2
View File
@@ -15,7 +15,7 @@ export class AppActivityItem {
title: string
}) {
if ((!packageName) || (!activityName)) {
throw new Error('incomplete app activity')
throw new IncompleteAppActivityItemException('incomplete app activity')
}
this.packageName = packageName
@@ -49,7 +49,7 @@ export class RemovedAppActivityItem {
activityName: string
}) {
if ((!packageName) || (!activityName)) {
throw new Error('incomplete app activity')
throw new IncompleteAppActivityItemException('incomplete app activity')
}
this.packageName = packageName
@@ -68,3 +68,5 @@ export class RemovedAppActivityItem {
this.activityName
])
}
export class IncompleteAppActivityItemException extends Error {}
+7 -5
View File
@@ -57,7 +57,7 @@ export class TimelimitRule {
assertIdWithinFamily(categoryId)
if (maxTimeInMillis < 0 || (!Number.isSafeInteger(maxTimeInMillis))) {
throw new Error('maxTimeInMillis must be >= 0')
throw new ParseTimeLimitRuleException('maxTimeInMillis must be >= 0')
}
if (!(
@@ -65,7 +65,7 @@ export class TimelimitRule {
dayMask < 0 ||
dayMask > (1 | 2 | 4 | 8 | 16 | 32 | 64)
)) {
throw new Error('invalid day mask')
throw new ParseTimeLimitRuleException('invalid day mask')
}
if (
@@ -74,15 +74,15 @@ export class TimelimitRule {
(!Number.isSafeInteger(sessionDurationMilliseconds)) ||
(!Number.isSafeInteger(sessionPauseMilliseconds))
) {
throw new Error()
throw new ParseTimeLimitRuleException()
}
if (start < MinuteOfDay.MIN || end > MinuteOfDay.MAX || start > end) {
throw new Error()
throw new ParseTimeLimitRuleException()
}
if (sessionDurationMilliseconds < 0 || sessionPauseMilliseconds < 0) {
throw new Error()
throw new ParseTimeLimitRuleException()
}
}
@@ -124,3 +124,5 @@ export interface SerializedTimeLimitRule {
dur?: number
pause?: number
}
export class ParseTimeLimitRuleException extends Error {}