Path: blob/trunk/third_party/closure/goog/testing/jsunitexception.js
4050 views
/**1* @license2* Copyright The Closure Library Authors.3* SPDX-License-Identifier: Apache-2.04*/56goog.provide('goog.testing.JsUnitException');7goog.setTestOnly();89goog.require('goog.testing.stacktrace');101112/**13* @param {string} comment A summary for the exception.14* @param {?string=} opt_message A description of the exception.15* @constructor16* @extends {Error}17* @final18*/19goog.testing.JsUnitException = function(comment, opt_message) {20'use strict';21this.isJsUnitException = true;22this.message =23goog.testing.JsUnitException.generateMessage(comment, opt_message);24this.stackTrace = goog.testing.stacktrace.get();25// These fields are for compatibility with jsUnitTestManager.26this.comment = comment || null;27this.jsUnitMessage = opt_message || '';2829// Ensure there is a stack trace.30if (Error.captureStackTrace) {31Error.captureStackTrace(this, goog.testing.JsUnitException);32} else {33this.stack = new Error().stack || '';34}35};36goog.inherits(goog.testing.JsUnitException, Error);3738/**39* @param {string} comment A summary for the exception.40* @param {?string=} opt_message A description of the exception.41* @return {string} Concatenated message42* @package43*/44goog.testing.JsUnitException.generateMessage = function(comment, opt_message) {45'use strict';46return (comment || '') + (comment && opt_message ? '\n' : '') +47(opt_message || '');48};495051/** @override */52goog.testing.JsUnitException.prototype.toString = function() {53'use strict';54return this.message || this.jsUnitMessage;55};565758