Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
801 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | const STRIP_FILENAME_RE = /^[^:]+: /;
|
---|
| 4 |
|
---|
| 5 | const format = err => {
|
---|
| 6 | if (err instanceof SyntaxError) {
|
---|
| 7 | err.name = "SyntaxError";
|
---|
| 8 | err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
---|
| 9 | err.hideStack = true;
|
---|
| 10 | } else if (err instanceof TypeError) {
|
---|
| 11 | err.name = null;
|
---|
| 12 | err.message = err.message.replace(STRIP_FILENAME_RE, "");
|
---|
| 13 | err.hideStack = true;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | return err;
|
---|
| 17 | };
|
---|
| 18 |
|
---|
| 19 | class LoaderError extends Error {
|
---|
| 20 | constructor(err) {
|
---|
| 21 | super();
|
---|
| 22 | const {
|
---|
| 23 | name,
|
---|
| 24 | message,
|
---|
| 25 | codeFrame,
|
---|
| 26 | hideStack
|
---|
| 27 | } = format(err);
|
---|
| 28 | this.name = "BabelLoaderError";
|
---|
| 29 | this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
|
---|
| 30 | this.hideStack = hideStack;
|
---|
| 31 | Error.captureStackTrace(this, this.constructor);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | module.exports = LoaderError; |
---|
Note:
See
TracBrowser
for help on using the repository browser.