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/css-tree/lib/utils/createCustomError.js
2019-08-11 20:48:02 +02:00

17 lines
543 B
JavaScript

module.exports = function createCustomError(name, message) {
// use Object.create(), because some VMs prevent setting line/column otherwise
// (iOS Safari 10 even throws an exception)
var error = Object.create(SyntaxError.prototype);
var errorStack = new Error();
error.name = name;
error.message = message;
Object.defineProperty(error, 'stack', {
get: function() {
return (errorStack.stack || '').replace(/^(.+\n){1,3}/, name + ': ' + message + '\n');
}
});
return error;
};