source: trip-planner-front/node_modules/babel-loader/lib/Error.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 801 bytes
Line 
1"use strict";
2
3const STRIP_FILENAME_RE = /^[^:]+: /;
4
5const 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
19class 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
36module.exports = LoaderError;
Note: See TracBrowser for help on using the repository browser.