diff --git a/lib/util/error.js b/lib/util/error.js index 09ff0ed3dc..85dd4747a6 100644 --- a/lib/util/error.js +++ b/lib/util/error.js @@ -88,20 +88,19 @@ shaka.util.Error = class { */ this.message = 'Shaka Error ' + categoryName + '.' + codeName + ' (' + this.data.toString() + ')'; + } - if (shaka.util.Error.createStack) { - try { - throw new Error(this.message); - } catch (e) { - /** - * A stack-trace showing where the error occurred. - * (Only available in uncompiled mode.) - * - * @const {string} - * @exportDoc - */ - this.stack = e.stack; - } + if (shaka.util.Error.createStack) { + try { + throw new Error(this.message || 'Shaka Error'); + } catch (e) { + /** + * A stack-trace showing where the error occurred. + * + * @const {string} + * @exportDoc + */ + this.stack = e.stack; } } } @@ -117,18 +116,15 @@ shaka.util.Error = class { }; -if (goog.DEBUG) { - /** - * If true, create a stack trace in Error objects. - * - * Only available in uncompiled mode, and disabled in tests to avoid issues - * with karma-jasmine. See comments in test/test/boot.js for details. - * - * @type {boolean} - */ - shaka.util.Error.createStack = true; -} - +/** + * If true, create a stack trace in Error objects. + * + * Disabled in tests to avoid issues with karma-jasmine. + * See comments in test/test/boot.js for details. + * + * @type {boolean} + */ +shaka.util.Error.createStack = true; /** * @enum {number} diff --git a/test/test/boot.js b/test/test/boot.js index 7b4d7fea83..4bf6b81be0 100644 --- a/test/test/boot.js +++ b/test/test/boot.js @@ -357,8 +357,8 @@ function configureJasmineEnvironment() { // Code in karma-jasmine's adapter will malform test failures when the // expectation message contains a stack trace, losing the failure message and // mixing up the stack trace of the failure. To avoid this, we modify - // shaka.util.Error not to create a stack trace. This trace is not available - // in production, and there is never any need for it in the tests. + // shaka.util.Error not to create a stack trace. There is never any need for + // this trace in the tests. // Shimming shaka.util.Error proved too complicated because of a combination // of compiler restrictions and ES6 language features, so this is by far the // simpler answer.