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:
@@ -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 {}
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user