PageRenderTime 294ms CodeModel.GetById 286ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/support/closure-library/closure/goog/debug/error.js

https://github.com/nickg33/skulpt
JavaScript | 45 lines | 9 code | 9 blank | 27 comment | 2 complexity | a28cb46943d82e509a221ac6d0d221af MD5 | raw file
 1// Copyright 2009 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/**
16 * @fileoverview Provides a base class for custom Error objects such that the
17 * stack is corectly maintained.
18 *
19*
20 */
21
22goog.provide('goog.debug.Error');
23
24
25
26/**
27 * Base class for custom error objects.
28 * @param {*=} opt_msg The message associated with the error.
29 * @constructor
30 * @extends {Error}
31 */
32goog.debug.Error = function(opt_msg) {
33
34  // Ensure there is a stack trace.
35  this.stack = new Error().stack || '';
36
37  if (opt_msg) {
38    this.message = String(opt_msg);
39  }
40};
41goog.inherits(goog.debug.Error, Error);
42
43
44/** @inheritDoc */
45goog.debug.Error.prototype.name = 'CustomError';