Path: blob/trunk/third_party/closure/goog/debug/error.js
2868 views
// Copyright 2009 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview Provides a base class for custom Error objects such that the16* stack is correctly maintained.17*18* You should never need to throw goog.debug.Error(msg) directly, Error(msg) is19* sufficient.20*21*/2223goog.provide('goog.debug.Error');24252627/**28* Base class for custom error objects.29* @param {*=} opt_msg The message associated with the error.30* @constructor31* @extends {Error}32*/33goog.debug.Error = function(opt_msg) {3435// Attempt to ensure there is a stack trace.36if (Error.captureStackTrace) {37Error.captureStackTrace(this, goog.debug.Error);38} else {39var stack = new Error().stack;40if (stack) {41this.stack = stack;42}43}4445if (opt_msg) {46this.message = String(opt_msg);47}4849/**50* Whether to report this error to the server. Setting this to false will51* cause the error reporter to not report the error back to the server,52* which can be useful if the client knows that the error has already been53* logged on the server.54* @type {boolean}55*/56this.reportErrorToServer = true;57};58goog.inherits(goog.debug.Error, Error);596061/** @override */62goog.debug.Error.prototype.name = 'CustomError';636465