chore(server): moved errors to dedicated file

This commit is contained in:
Roberto Tonino
2021-05-13 21:14:35 +02:00
parent 335819b2bb
commit 4a1d655523
2 changed files with 29 additions and 26 deletions

View File

@@ -13,3 +13,28 @@ export class BadRequestError extends Error {
}
export const isBadRequestError = (error: any) => error instanceof BadRequestError
export class QueueError extends Error {
constructor(message: string) {
super(message)
this.name = 'QueueError'
}
}
export class AlreadyInQueue extends QueueError {
item: any
silent: boolean
constructor(dwObj: any, silent: boolean) {
super(`${dwObj.artist} - ${dwObj.title} is already in queue.`)
this.name = 'AlreadyInQueue'
this.item = dwObj
this.silent = silent
}
}
export class NotLoggedIn extends QueueError {
constructor() {
super(`You must be logged in to start a download.`)
this.name = 'NotLoggedIn'
}
}