PageRenderTime 17ms CodeModel.GetById 6ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ydn/error.js

https://bitbucket.org/ytkyaw/ydn-base
JavaScript | 205 lines | 95 code | 43 blank | 67 comment | 28 complexity | 438e9067fe7bd0b07e295d4b4ef2ac25 MD5 | raw file
  1/**
  2 * @fileoverview About this file.
  3 *
  4 * User: kyawtun
  5 * Date: 7/9/12
  6 */
  7
  8goog.provide('ydn.error');
  9goog.provide('ydn.error.ArgumentException');
 10goog.provide('ydn.error.NotImplementedException');
 11goog.provide('ydn.error.ConstraintError');
 12goog.provide('ydn.error.NotSupportedException');
 13goog.provide('ydn.error.InternalError');
 14goog.provide('ydn.error.InvalidOperationException');
 15goog.provide('ydn.error.InvalidOperationError');
 16
 17
 18
 19
 20/**
 21 * Base class for custom error objects.
 22 * @param {*=} opt_msg The message associated with the error.
 23 * @constructor
 24 * @extends {Error}
 25 */
 26ydn.error.ArgumentException = function(opt_msg) {
 27
 28  // Ensure there is a stack trace.
 29  if (Error.captureStackTrace) {
 30    Error.captureStackTrace(this, ydn.error.ArgumentException);
 31  } else {
 32    this.stack = new Error().stack || '';
 33  }
 34
 35  if (opt_msg) {
 36    this.message = String(opt_msg);
 37  }
 38  this.name = 'ydn.error.ArgumentException';
 39};
 40goog.inherits(ydn.error.ArgumentException, Error);
 41
 42/// FIXME: how come compiler strip out prototype name ?
 43
 44//
 45///** @override */
 46//ydn.error.ArgumentException.prototype.name = 'ydn.ArgumentException';
 47
 48
 49
 50/**
 51 * Base class for custom error objects.
 52 * @param {*=} opt_msg The message associated with the error.
 53 * @constructor
 54 * @extends {Error}
 55 */
 56ydn.error.NotSupportedException = function(opt_msg) {
 57
 58  // Ensure there is a stack trace.
 59  if (Error.captureStackTrace) {
 60    Error.captureStackTrace(this, ydn.error.NotSupportedException);
 61  } else {
 62    this.stack = new Error().stack || '';
 63  }
 64
 65  if (opt_msg) {
 66    this.message = String(opt_msg);
 67  }
 68  this.name = 'ydn.error.NotSupportedException';
 69};
 70goog.inherits(ydn.error.ArgumentException, Error);
 71
 72/** @override */
 73ydn.error.NotSupportedException.prototype.name = 'ydn.error.NotSupportedException';
 74
 75
 76/**
 77 * Base class for custom error objects.
 78 * @param {*=} opt_msg The message associated with the error.
 79 * @constructor
 80 * @extends {Error}
 81 */
 82ydn.error.NotImplementedException = function(opt_msg) {
 83
 84  // Ensure there is a stack trace.
 85  if (Error.captureStackTrace) {
 86    Error.captureStackTrace(this, ydn.error.NotImplementedException);
 87  } else {
 88    this.stack = new Error().stack || '';
 89  }
 90
 91  if (opt_msg) {
 92    this.message = String(opt_msg);
 93  }
 94  this.name = 'ydn.error.NotImplementedException';
 95};
 96goog.inherits(ydn.error.NotImplementedException, Error);
 97
 98///** @override */
 99//ydn.error.NotImplementedException.prototype.name = 'ydn.NotImplementedException';
100
101
102
103/**
104 * Base class for custom error objects.
105 * @param {*=} opt_msg The message associated with the error.
106 * @constructor
107 * @extends {Error}
108 */
109ydn.error.InternalError = function(opt_msg) {
110
111  // Ensure there is a stack trace.
112  if (Error.captureStackTrace) {
113    Error.captureStackTrace(this, ydn.error.InternalError);
114  } else {
115    this.stack = new Error().stack || '';
116  }
117
118  if (opt_msg) {
119    this.message = String(opt_msg);
120  }
121  this.name = 'ydn.error.InternalError';
122};
123goog.inherits(ydn.error.InternalError, Error);
124
125ydn.error.InternalError.prototype.name = 'ydn.InternalError';
126
127
128/**
129 * Base class for custom error objects.
130 * @param {*=} opt_msg The message associated with the error.
131 * @constructor
132 * @extends {Error}
133 */
134ydn.error.ConstraintError = function(opt_msg) {
135
136  // Ensure there is a stack trace.
137  if (Error.captureStackTrace) {
138    Error.captureStackTrace(this, ydn.error.ConstraintError);
139  } else {
140    this.stack = new Error().stack || '';
141  }
142
143  if (opt_msg) {
144    this.message = String(opt_msg);
145  }
146  this.name = 'ydn.error.ConstraintError';
147};
148goog.inherits(ydn.error.ConstraintError, Error);
149
150ydn.error.ConstraintError.prototype.name = 'ydn.error.ConstraintError';
151
152
153
154/**
155 * Base class for custom error objects.
156 * @param {*=} opt_msg The message associated with the error.
157 * @constructor
158 * @extends {Error}
159 */
160ydn.error.InvalidOperationException = function(opt_msg) {
161
162  // Ensure there is a stack trace.
163  if (Error.captureStackTrace) {
164    Error.captureStackTrace(this, ydn.error.InvalidOperationException);
165  } else {
166    this.stack = new Error().stack || '';
167  }
168
169  if (opt_msg) {
170    this.message = String(opt_msg);
171  }
172  this.name = 'ydn.error.InvalidOperationException';
173};
174goog.inherits(ydn.error.ArgumentException, Error);
175
176///** @override */
177//ydn.error.InvalidOperationException.prototype.name = 'ydn.InvalidOperationException';
178
179
180
181/**
182 * Base class for custom error objects.
183 * @param {*=} opt_msg The message associated with the error.
184 * @constructor
185 * @extends {Error}
186 */
187ydn.error.InvalidOperationError = function(opt_msg) {
188
189  // Ensure there is a stack trace.
190  if (Error.captureStackTrace) {
191    Error.captureStackTrace(this, ydn.error.InvalidOperationError);
192  } else {
193    this.stack = new Error().stack || '';
194  }
195
196  if (opt_msg) {
197    this.message = String(opt_msg);
198  }
199  this.name = 'ydn.error.InvalidOperationError';
200};
201goog.inherits(ydn.error.InvalidOperationError, Error);
202
203//
204///** @override */
205//ydn.error.InvalidOperationError.prototype.name = 'ydn.InvalidOperationError';