cat-bookmarker/assets/node_modules/babel-loader/lib/Error.js

36 lines
801 B
JavaScript
Raw Normal View History

2024-03-10 18:52:04 +00:00
"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;