This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/babel-loader/lib/Error.js
2019-08-11 20:48:02 +02:00

36 lines
No EOL
801 B
JavaScript

"use strict";
const STRIP_FILENAME_RE = /^[^:]+: /;
const format = err => {
if (err instanceof SyntaxError) {
err.name = "SyntaxError";
err.message = err.message.replace(STRIP_FILENAME_RE, "");
err.hideStack = true;
} else if (err instanceof TypeError) {
err.name = null;
err.message = err.message.replace(STRIP_FILENAME_RE, "");
err.hideStack = true;
}
return err;
};
class LoaderError extends Error {
constructor(err) {
super();
const {
name,
message,
codeFrame,
hideStack
} = format(err);
this.name = "BabelLoaderError";
this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
this.hideStack = hideStack;
Error.captureStackTrace(this, this.constructor);
}
}
module.exports = LoaderError;