main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
409 bytes
|
Line | |
---|
1 | export default function createErrorType(name, init) {
|
---|
2 | function E(...args) {
|
---|
3 | if (!Error.captureStackTrace) {
|
---|
4 | this.stack = new Error().stack;
|
---|
5 | } else {
|
---|
6 | Error.captureStackTrace(this, this.constructor);
|
---|
7 | }
|
---|
8 | [this.message] = args;
|
---|
9 | if (init) {
|
---|
10 | init.apply(this, args);
|
---|
11 | }
|
---|
12 | }
|
---|
13 | E.prototype = new Error();
|
---|
14 | E.prototype.name = name;
|
---|
15 | E.prototype.constructor = E;
|
---|
16 | return E;
|
---|
17 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.