Debian Codegraph @

closure-library/closure/goog/testing/jsunitexception.js

raw
1 // Copyright 2017 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.provide('goog.testing.JsUnitException');
16 goog.setTestOnly();
17
18 goog.require('goog.testing.stacktrace');
19
20
21 /**
22 * @param {string} comment A summary for the exception.
23 * @param {?string=} opt_message A description of the exception.
24 * @constructor
25 * @extends {Error}
26 * @final
27 */
28 goog.testing.JsUnitException = function(comment, opt_message) {
29 this.isJsUnitException = true;
30 this.message = (comment ? comment : '') +
31 (comment && opt_message ? '\n' : '') + (opt_message ? opt_message : '');
32 this.stackTrace = goog.testing.stacktrace.get();
33 // These fields are for compatibility with jsUnitTestManager.
34 this.comment = comment || null;
35 this.jsUnitMessage = opt_message || '';
36
37 // Ensure there is a stack trace.
38 if (Error.captureStackTrace) {
39 Error.captureStackTrace(this, goog.testing.JsUnitException);
40 } else {
41 this.stack = new Error().stack || '';
42 }
43 };
44 goog.inherits(goog.testing.JsUnitException, Error);
45
46
47 /** @override */
48 goog.testing.JsUnitException.prototype.toString = function() {
49 return this.message;
50 };