-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.ts
More file actions
59 lines (54 loc) · 1.44 KB
/
errors.ts
File metadata and controls
59 lines (54 loc) · 1.44 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Custom error classes for bargs.
*
* Defines the error hierarchy used throughout bargs:
*
* - {@link BargsError} - Base class for all bargs errors
* - {@link HelpError} - Triggers help text display when user needs guidance
* - {@link ValidationError} - Thrown when configuration validation fails
*
* @packageDocumentation
*/
/**
* Custom error class for bargs errors.
*
* @group Errors
*/
export class BargsError extends Error {
constructor(message: string) {
super(message);
this.name = 'BargsError';
}
}
/**
* Error that triggers help text display. Thrown when the user needs guidance.
*
* @param message - Error message to show before help text
* @param command - Command name for command-specific help, undefined for
* general help
* @group Errors
*/
export class HelpError extends BargsError {
readonly command?: string;
constructor(message: string, command?: string) {
super(message);
this.name = 'HelpError';
this.command = command;
}
}
/**
* Error thrown when bargs config validation fails.
*
* @param message - Description of what's invalid
* @param path - Dot-notation path to the invalid property (e.g.,
* "options.verbose.aliases[0]")
* @group Errors
*/
export class ValidationError extends BargsError {
readonly path: string;
constructor(path: string, message: string) {
super(`Invalid config at "${path}": ${message}`);
this.name = 'ValidationError';
this.path = path;
}
}