main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
781 bytes
|
Line | |
---|
1 | const STRIP_FILENAME_RE = /^[^:]+: /;
|
---|
2 | const format = err => {
|
---|
3 | if (err instanceof SyntaxError) {
|
---|
4 | err.name = "SyntaxError";
|
---|
5 | err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
---|
6 | err.hideStack = true;
|
---|
7 | } else if (err instanceof TypeError) {
|
---|
8 | err.name = null;
|
---|
9 | err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
---|
10 | err.hideStack = true;
|
---|
11 | }
|
---|
12 | return err;
|
---|
13 | };
|
---|
14 | class LoaderError extends Error {
|
---|
15 | constructor(err) {
|
---|
16 | super();
|
---|
17 | const {
|
---|
18 | name,
|
---|
19 | message,
|
---|
20 | codeFrame,
|
---|
21 | hideStack
|
---|
22 | } = format(err);
|
---|
23 | this.name = "BabelLoaderError";
|
---|
24 | this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
|
---|
25 | this.hideStack = hideStack;
|
---|
26 | Error.captureStackTrace(this, this.constructor);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | module.exports = LoaderError; |
---|
Note:
See
TracBrowser
for help on using the repository browser.