PageRenderTime 50ms CodeModel.GetById 30ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ydn/debug/error.js

https://bitbucket.org/ytkyaw/ydn-base
JavaScript | 166 lines | 59 code | 36 blank | 71 comment | 8 complexity | b59fa1e37e9448bb180bbb5e3c5ec0af MD5 | raw file
  1// Licensed under the Apache License, Version 2.0 (the "License");
  2// you may not use this file except in compliance with the License.
  3// You may obtain a copy of the License at
  4//
  5//      http://www.apache.org/licenses/LICENSE-2.0
  6//
  7// Unless required by applicable law or agreed to in writing, software
  8// distributed under the License is distributed on an "AS-IS" BASIS,
  9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 10// See the License for the specific language governing permissions and
 11// limitations under the License.
 12
 13
 14/**
 15 * @fileoverview Utilities function for debug.
 16 *
 17 * NOTE: these code are stripped using compiler prefix feature.
 18 * See more detail in tools/strip_debug.txt file.
 19 *
 20 * @author kyawtun@yathit.com (Kyaw Tun)
 21 */
 22
 23
 24
 25goog.provide('ydn.debug.error.ArgumentException');
 26goog.provide('ydn.debug.error.ConstraintError');
 27goog.provide('ydn.debug.error.InternalError');
 28goog.provide('ydn.debug.error.InvalidOperationException');
 29goog.provide('ydn.debug.error.NotImplementedException');
 30goog.provide('ydn.debug.error.NotSupportedException');
 31goog.provide('ydn.debug.error.TypeError');
 32
 33goog.require('goog.debug.Error');
 34
 35
 36
 37/**
 38 * Base class for custom error objects.
 39 * @param {*=} opt_msg The message associated with the error.
 40 * @constructor
 41 * @extends {goog.debug.Error}
 42 */
 43ydn.debug.error.ArgumentException = function(opt_msg) {
 44  goog.base(this, opt_msg);
 45  this.name = 'ydn.error.ArgumentException';
 46};
 47goog.inherits(ydn.debug.error.ArgumentException, goog.debug.Error);
 48
 49
 50
 51/**
 52 * Base class for custom error objects.
 53 * @param {*=} opt_msg The message associated with the error.
 54 * @constructor
 55 * @extends {goog.debug.Error}
 56 */
 57ydn.debug.error.TypeError = function(opt_msg) {
 58  goog.base(this, opt_msg);
 59  this.name = 'ydn.error.TypeError';
 60};
 61goog.inherits(ydn.debug.error.TypeError, goog.debug.Error);
 62
 63
 64
 65/**
 66 * Base class for custom error objects.
 67 * @param {*=} opt_msg The message associated with the error.
 68 * @constructor
 69 * @extends {goog.debug.Error}
 70 */
 71ydn.debug.error.NotSupportedException = function(opt_msg) {
 72  goog.base(this, opt_msg);
 73  this.name = 'ydn.error.NotSupportedException';
 74};
 75goog.inherits(ydn.debug.error.NotSupportedException, goog.debug.Error);
 76
 77
 78
 79/**
 80 * Base class for custom error objects.
 81 * @param {*=} opt_msg The message associated with the error.
 82 * @constructor
 83 * @extends {goog.debug.Error}
 84 */
 85ydn.debug.error.NotImplementedException = function(opt_msg) {
 86  goog.base(this, opt_msg);
 87  this.name = 'ydn.error.NotImplementedException';
 88};
 89goog.inherits(ydn.debug.error.NotImplementedException, goog.debug.Error);
 90
 91
 92
 93/**
 94 * Base class for custom error objects.
 95 * @param {*=} opt_msg The message associated with the error.
 96 * @constructor
 97 * @extends {goog.debug.Error}
 98 */
 99ydn.debug.error.InvalidOperationException = function(opt_msg) {
100  goog.base(this, opt_msg);
101  this.name = 'ydn.error.InvalidOperationException';
102};
103goog.inherits(ydn.debug.error.InvalidOperationException, goog.debug.Error);
104
105
106
107/**
108 * Base class for custom error objects.
109 * @param {*=} opt_msg The message associated with the error.
110 * @constructor
111 * @extends {Error}
112 */
113ydn.debug.error.InternalError = function(opt_msg) {
114
115  // Ensure there is a stack trace.
116  if (Error.captureStackTrace) {
117    Error.captureStackTrace(this, ydn.debug.error.InternalError);
118  } else {
119    this.stack = new Error().stack || '';
120  }
121
122  if (opt_msg) {
123    this.message = String(opt_msg);
124  }
125  this.name = 'ydn.error.InternalError';
126};
127goog.inherits(ydn.debug.error.InternalError, Error);
128
129
130/**
131 * Name of error.
132 * @type {string}
133 */
134ydn.debug.error.InternalError.prototype.name = 'ydn.error.InternalError';
135
136
137
138/**
139 * Base class for custom error objects.
140 * @param {*=} opt_msg The message associated with the error.
141 * @constructor
142 * @extends {Error}
143 */
144ydn.debug.error.ConstraintError = function(opt_msg) {
145
146  // Ensure there is a stack trace.
147  if (Error.captureStackTrace) {
148    Error.captureStackTrace(this, ydn.debug.error.ConstraintError);
149  } else {
150    this.stack = new Error().stack || '';
151  }
152
153  if (opt_msg) {
154    this.message = String(opt_msg);
155  }
156  this.name = 'ydn.error.ConstraintError';
157};
158goog.inherits(ydn.debug.error.ConstraintError, Error);
159
160
161/**
162 * Name of error.
163 * @type {string}
164 */
165ydn.debug.error.ConstraintError.prototype.name = 'ydn.error.ConstraintError';
166