Refactor exception usage

This commit is contained in:
Jonas Lochmann 2020-09-28 02:00:00 +02:00
parent d68b425e0e
commit 8d65c5d777
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
148 changed files with 2061 additions and 769 deletions

View file

@ -21,6 +21,8 @@ import { config } from '../../../config'
import { VisibleConnectedDevicesManager } from '../../../connected-devices'
import { Database } from '../../../database'
import { generateVersionId } from '../../../util/token'
import { SourceUserNotFoundException } from './exception/illegal-state'
import { InvalidChildActionIntegrityValue } from './exception/integrity'
export class Cache {
readonly familyId: string
@ -84,7 +86,7 @@ export class Cache {
})
if (!userEntryUnsafe) {
throw new Error('user not found')
throw new SourceUserNotFoundException()
}
return userEntryUnsafe.secondPasswordHash
@ -102,11 +104,11 @@ export class Cache {
})
if (!userEntryUnsafe) {
throw new Error('user not found')
throw new SourceUserNotFoundException()
}
if (!userEntryUnsafe.secondPasswordHash) {
throw new Error('user does not have a password')
throw new InvalidChildActionIntegrityValue()
}
return userEntryUnsafe.secondPasswordHash