1 | export type ErrorMeta = {
|
2 | type: `none`;
|
3 | } | {
|
4 | type: `usage`;
|
5 | };
|
6 | /**
|
7 | * An error with metadata telling clipanion how to print it
|
8 | *
|
9 | * Errors with this metadata property will have their name and message printed, but not the
|
10 | * stacktrace.
|
11 | *
|
12 | * This should be used for errors where the message is the part that's important but the stacktrace is useless.
|
13 | * Some examples of where this might be useful are:
|
14 | *
|
15 | * - Invalid input by the user (see `UsageError`)
|
16 | * - A HTTP connection fails, the user is shown "Failed To Fetch Data: Could not connect to server example.com" without stacktrace
|
17 | * - A command in which the user enters credentials doesn't want to show a stacktract when the user enters invalid credentials
|
18 | * - ...
|
19 | */
|
20 | export interface ErrorWithMeta extends Error {
|
21 | /**
|
22 | * Metadata detailing how clipanion should print this error
|
23 | */
|
24 | readonly clipanion: ErrorMeta;
|
25 | }
|
26 | /**
|
27 | * A generic usage error with the name `UsageError`.
|
28 | *
|
29 | * It should be used over `Error` only when it's the user's fault.
|
30 | */
|
31 | export declare class UsageError extends Error {
|
32 | clipanion: ErrorMeta;
|
33 | constructor(message: string);
|
34 | }
|
35 | export declare class UnknownSyntaxError extends Error {
|
36 | readonly input: Array<string>;
|
37 | readonly candidates: Array<{
|
38 | usage: string;
|
39 | reason: string | null;
|
40 | }>;
|
41 | clipanion: ErrorMeta;
|
42 | constructor(input: Array<string>, candidates: Array<{
|
43 | usage: string;
|
44 | reason: string | null;
|
45 | }>);
|
46 | }
|
47 | export declare class AmbiguousSyntaxError extends Error {
|
48 | readonly input: Array<string>;
|
49 | readonly usages: Array<string>;
|
50 | clipanion: ErrorMeta;
|
51 | constructor(input: Array<string>, usages: Array<string>);
|
52 | }
|