-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy patherrors.js
49 lines (39 loc) · 1.2 KB
/
errors.js
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
import process from 'node:process';
import pico from 'picocolors';
import {stripIndents, stripIndent} from 'common-tags';
export class FileNotFoundError extends Error {
constructor(file = '', paths = [], ...params) {
const message = pico.red(stripIndent`
Error: File not found: ${file}
Current working directory: ${process.cwd()}
Searched in: ${paths.length > 0 ? paths.join(', ') : '-'}
`);
super([message, ...params]);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, FileNotFoundError);
}
this.file = file;
}
}
export class NoCssError extends Error {
constructor(...params) {
const message = pico.red(stripIndents`
Error: No stylesheets found in document and no css was specified in the options
`);
super([message, ...params]);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, FileNotFoundError);
}
}
}
export class ConfigError extends Error {
constructor(msg, ...params) {
const message = pico.red(stripIndents`
ConfigError: ${msg}
`);
super([message, ...params]);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, FileNotFoundError);
}
}
}