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
@@ -19,6 +19,7 @@ import * as Sequelize from 'sequelize'
import { AddUsedTimeAction } from '../../../../action'
import { MinuteOfDay } from '../../../../util/minuteofday'
import { Cache } from '../cache'
import { MissingCategoryException } from '../exception/missing-item'
export const getRoundedTimestamp = () => {
const now = Date.now()
@@ -29,7 +30,7 @@ export const getRoundedTimestamp = () => {
const dayLengthInMinutes = MinuteOfDay.LENGTH
const dayLengthInMs = dayLengthInMinutes * 1000 * 60
export async function dispatchAddUsedTime ({ deviceId, action, cache }: {
export async function dispatchAddUsedTime ({ action, cache }: {
deviceId: string
action: AddUsedTimeAction
cache: Cache
@@ -50,7 +51,7 @@ export async function dispatchAddUsedTime ({ deviceId, action, cache }: {
})
// verify that the category exists
if (!categoryEntryUnsafe) {
throw new Error('invalid category id')
throw new MissingCategoryException()
}
const categoryEntry = {