1 | 'use strict';
|
2 | var debug = require('debug');
|
3 |
|
4 | function SilentError(message) {
|
5 | if (!(this instanceof SilentError)) {
|
6 | throw new TypeError('SilentError must be instantiated with `new`');
|
7 | }
|
8 |
|
9 | this.name = 'SilentError';
|
10 | this.message = message;
|
11 | this.isSilentError = true;
|
12 |
|
13 | if (process.env.SILENT_ERROR === 'verbose' || process.env.EMBER_VERBOSE_ERRORS === 'true') {
|
14 | this.stack = (new Error()).stack;
|
15 | this.suppressedStacktrace = false;
|
16 | } else {
|
17 | this.suppressedStacktrace = true;
|
18 | }
|
19 | }
|
20 |
|
21 | SilentError.prototype = Object.create(Error.prototype);
|
22 | SilentError.prototype.constructor = SilentError;
|
23 |
|
24 | SilentError.debugOrThrow = function debugOrThrow(label, e) {
|
25 |
|
26 | if(e && e.isSilentError) {
|
27 |
|
28 | debug(label)(e);
|
29 | } else {
|
30 |
|
31 | throw e;
|
32 | }
|
33 | };
|
34 |
|
35 | module.exports = SilentError;
|