From d67ffa3e204c0903e7a0f6ca8ca98384af230ba4 Mon Sep 17 00:00:00 2001 From: seditionist <84986004+seditionist@users.noreply.github.com> Date: Thu, 17 Aug 2023 00:11:18 -0400 Subject: [PATCH] created custom errors --- src/utils/constants.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 6d24d71..7cbc749 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -282,3 +282,38 @@ export const FORMATTED_RIFTS_CLOSED = 'Rifts closed'; export const INVALID_FORMAT_ERROR = 'Invalid hiscores format'; export const PLAYER_NOT_FOUND_ERROR = 'Player not found'; +export class InvalidFormatError extends Error { + __proto__ = Error; + + constructor() { + super('Invalid hiscores format'); + Object.setPrototypeOf(this, InvalidFormatError.prototype); + } +} + +export class InvalidRSNError extends Error { + __proto__ = Error; + + constructor(message: string) { + super(message); + Object.setPrototypeOf(this, InvalidRSNError.prototype); + } +} + +export class PlayerNotFoundError extends Error { + __proto__ = Error; + + constructor() { + super('Player not found'); + Object.setPrototypeOf(this, PlayerNotFoundError.prototype); + } +} + +export class HiScoresError extends Error { + __proto__ = Error; + + constructor() { + super('HiScores not responding'); + Object.setPrototypeOf(this, HiScoresError.prototype); + } +}