/
error.ts
43 lines (39 loc) · 936 Bytes
/
error.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @public
*/
export interface SpawnErrorOptions {
exitCode: number;
command: string;
args: readonly string[];
stdout: string;
stderr: string;
}
/**
* @public
*/
export class SpawnError extends Error {
public readonly exitCode: number;
public readonly command: string;
public readonly args: readonly string[];
public readonly stdout: string;
public readonly stderr: string;
constructor(options: SpawnErrorOptions) {
super(
[
`Command failed with exit code ${options.exitCode}: ${
options.command
} ${options.args.join(" ")}`,
options.stderr.trim(),
options.stdout.trim()
]
.filter(Boolean)
.join("\n")
);
this.exitCode = options.exitCode;
this.command = options.command;
this.args = options.args;
this.stdout = options.stdout;
this.stderr = options.stderr;
}
}
SpawnError.prototype.name = "SpawnError";