(baseErrorType, errorName)
| 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 |
no test coverage detected