MCPcopy
hub / github.com/pixijs/pixijs / extendError

Function extendError

transcoders/basis/basis_transcoder.js:390–407  ·  view source on GitHub ↗
(baseErrorType, errorName)

Source from the content-addressed store, hash-verified

388
389 return new Function('body', `return function ${name}() {\n` + ` "use strict";` + ` return body.apply(this, arguments);\n` + `};\n`)(body);
390 } function extendError(baseErrorType, errorName)
391 {
392 const errorClass = createNamedFunction(errorName, function (message)
393 {
394 this.name = errorName; this.message = message; const stack = new Error(message).stack;
395
396 if (stack !== undefined) { this.stack = `${this.toString()}\n${stack.replace(/^Error(:[^\n]*)?\n/, '')}`; }
397 });
398
399 errorClass.prototype = Object.create(baseErrorType.prototype); errorClass.prototype.constructor = errorClass; errorClass.prototype.toString = function ()
400 {
401 if (this.message === undefined) { return this.name; }
402
403 return `${this.name}: ${this.message}`;
404 };
405
406 return errorClass;
407 } let BindingError;
408
409 function throwBindingError(message) { throw new BindingError(message); } let InternalError;
410

Callers 1

Calls 3

createMethod · 0.80
createNamedFunctionFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected