UNPKG

475 BJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.default = createErrorType;
5
6function createErrorType(name, init) {
7 function E(...args) {
8 if (!Error.captureStackTrace) {
9 this.stack = new Error().stack;
10 } else {
11 Error.captureStackTrace(this, this.constructor);
12 }
13
14 [this.message] = args;
15
16 if (init) {
17 init.apply(this, args);
18 }
19 }
20
21 E.prototype = new Error();
22 E.prototype.name = name;
23 E.prototype.constructor = E;
24 return E;
25}
\No newline at end of file