Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/testing/jsunitexception.js
4050 views
1
/**
2
* @license
3
* Copyright The Closure Library Authors.
4
* SPDX-License-Identifier: Apache-2.0
5
*/
6
7
goog.provide('goog.testing.JsUnitException');
8
goog.setTestOnly();
9
10
goog.require('goog.testing.stacktrace');
11
12
13
/**
14
* @param {string} comment A summary for the exception.
15
* @param {?string=} opt_message A description of the exception.
16
* @constructor
17
* @extends {Error}
18
* @final
19
*/
20
goog.testing.JsUnitException = function(comment, opt_message) {
21
'use strict';
22
this.isJsUnitException = true;
23
this.message =
24
goog.testing.JsUnitException.generateMessage(comment, opt_message);
25
this.stackTrace = goog.testing.stacktrace.get();
26
// These fields are for compatibility with jsUnitTestManager.
27
this.comment = comment || null;
28
this.jsUnitMessage = opt_message || '';
29
30
// Ensure there is a stack trace.
31
if (Error.captureStackTrace) {
32
Error.captureStackTrace(this, goog.testing.JsUnitException);
33
} else {
34
this.stack = new Error().stack || '';
35
}
36
};
37
goog.inherits(goog.testing.JsUnitException, Error);
38
39
/**
40
* @param {string} comment A summary for the exception.
41
* @param {?string=} opt_message A description of the exception.
42
* @return {string} Concatenated message
43
* @package
44
*/
45
goog.testing.JsUnitException.generateMessage = function(comment, opt_message) {
46
'use strict';
47
return (comment || '') + (comment && opt_message ? '\n' : '') +
48
(opt_message || '');
49
};
50
51
52
/** @override */
53
goog.testing.JsUnitException.prototype.toString = function() {
54
'use strict';
55
return this.message || this.jsUnitMessage;
56
};
57
58