-
Notifications
You must be signed in to change notification settings - Fork 1
/
exceptions.ts
26 lines (25 loc) · 1.06 KB
/
exceptions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { entryName, entryId } from "./types"
/**
* Raised when a given category does not exist in the compendium
* @param {string} target_category Non-existant input category that caused error
*/
export class NoCategoryError extends Error {
constructor(target_category: string) {
super("Category '" + String(target_category) + "' not found. Available categories are 'creatures', 'equipment', 'materials', 'monsters', or 'treasure'")
}
}
/**
* Raised when a given entry does not exist in the compendium
* @param {entryName | entryId} target_entry Non-existant input entry that causes error
*/
export class NoEntryError extends Error {
constructor(target_entry: entryName | entryId){
if (typeof(target_entry) == "number"){
super("Entry with ID "+ String(target_entry) + " not found.")
} else if (typeof(target_entry) == "string"){
super("Entry with name '" + target_entry + "' not found.")
} else {
super("Type '" + typeof(target_entry) + "' not a valid entry type. Must be INT or STR")
}
}
}