UNPKG

835 BJavaScriptView Raw
1/**
2 * @class BlueprintError
3 *
4 * Base class for all errors in Blueprint. Each BlueprintError has an unique code,
5 * an error message, and optional details about the error.
6 *
7 * @param code Unique error code
8 * @param message Error message
9 * @param details Optional details about the error
10 * @constructor
11 */
12class BlueprintError extends Error {
13 constructor (code, message, details) {
14 super (message);
15
16 if (typeof Error.captureStackTrace === 'function') {
17 Error.captureStackTrace (this, this.constructor);
18 }
19 else {
20 this.stack = (new Error(message)).stack;
21 }
22
23 this.name = this.constructor.name;
24 this.code = code;
25 this.message = message;
26 this.details = details;
27 }
28
29 accept (v) {
30 v.visitBlueprintError (this);
31 }
32}
33
34module.exports = BlueprintError;