convoker 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/error.js CHANGED
@@ -1,10 +1,100 @@
1
- import { C as n, H as s, I as a, M as e, a as i, T as t, U as E } from "./chunks/error-CyKscMUD.js";
2
- export {
3
- n as ConvokerError,
4
- s as HelpAskedError,
5
- a as InputValidationError,
6
- e as MissingRequiredArgumentError,
7
- i as MissingRequiredOptionError,
8
- t as TooManyArgumentsError,
9
- E as UnknownOptionError
10
- };
1
+ /**
2
+ * Thrown when the command fails to validate an input.
3
+ */
4
+ export class InputValidationError extends Error {
5
+ /**
6
+ * Creates a new input validation error.
7
+ * @param messages The messages.
8
+ */
9
+ constructor(messages) {
10
+ super(`Validation failed: ${messages.join(", ")}`);
11
+ this.messages = messages;
12
+ }
13
+ }
14
+ /**
15
+ * A Convoker-related error. These are usually handled by default.
16
+ */
17
+ export class ConvokerError extends Error {
18
+ /**
19
+ * Creates a new Convoker error.
20
+ * @param message The message.
21
+ * @param command The command.
22
+ */
23
+ constructor(message, command) {
24
+ super(message);
25
+ this.command = command;
26
+ }
27
+ /**
28
+ * Prints the error's message.
29
+ */
30
+ print() {
31
+ console.error(this.message);
32
+ }
33
+ }
34
+ /**
35
+ * When the user asks for help.
36
+ */
37
+ export class HelpAskedError extends ConvokerError {
38
+ /**
39
+ * Creates a new help asked error.
40
+ * @param command The command.
41
+ */
42
+ constructor(command) {
43
+ super("user asked for help!", command);
44
+ }
45
+ }
46
+ /**
47
+ * When you pass too many arguments.
48
+ */
49
+ export class TooManyArgumentsError extends ConvokerError {
50
+ /**
51
+ * Creates a new too many arguments error.
52
+ * @param command The command.
53
+ */
54
+ constructor(command) {
55
+ super("too many arguments!", command);
56
+ }
57
+ }
58
+ /**
59
+ * When you pass an unknown option, when unknown options aren't allowed.
60
+ */
61
+ export class UnknownOptionError extends ConvokerError {
62
+ /**
63
+ * Creates a new unknown option error.
64
+ * @param command The command.
65
+ * @param key The key.
66
+ */
67
+ constructor(command, key) {
68
+ super(`unknown option: ${key}!`, command);
69
+ this.key = key;
70
+ }
71
+ }
72
+ /**
73
+ * When a required option is missing.
74
+ */
75
+ export class MissingRequiredOptionError extends ConvokerError {
76
+ /**
77
+ * Creates a new missing required option error.
78
+ * @param command The command.
79
+ * @param key The key.
80
+ * @param entry The entry.
81
+ */
82
+ constructor(command, key, entry) {
83
+ super(`missing required option: ${key}!`, command);
84
+ this.key = key;
85
+ this.entry = entry;
86
+ }
87
+ }
88
+ export class MissingRequiredArgumentError extends ConvokerError {
89
+ /**
90
+ * Creates a new missing required argument error.
91
+ * @param command The command.
92
+ * @param key The key.
93
+ * @param entry The entry.
94
+ */
95
+ constructor(command, key, entry) {
96
+ super(`missing required positional argument: ${key}!`, command);
97
+ this.key = key;
98
+ this.entry = entry;
99
+ }
100
+ }