PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  1. /**
  2. * @fileoverview About this file.
  3. *
  4. * User: kyawtun
  5. * Date: 7/9/12
  6. */
  7. goog.provide('ydn.error');
  8. goog.provide('ydn.error.ArgumentException');
  9. goog.provide('ydn.error.NotImplementedException');
  10. goog.provide('ydn.error.ConstraintError');
  11. goog.provide('ydn.error.NotSupportedException');
  12. goog.provide('ydn.error.InternalError');
  13. goog.provide('ydn.error.InvalidOperationException');
  14. goog.provide('ydn.error.InvalidOperationError');
  15. /**
  16. * Base class for custom error objects.
  17. * @param {*=} opt_msg The message associated with the error.
  18. * @constructor
  19. * @extends {Error}
  20. */
  21. ydn.error.ArgumentException = function(opt_msg) {
  22. // Ensure there is a stack trace.
  23. if (Error.captureStackTrace) {
  24. Error.captureStackTrace(this, ydn.error.ArgumentException);
  25. } else {
  26. this.stack = new Error().stack || '';
  27. }
  28. if (opt_msg) {
  29. this.message = String(opt_msg);
  30. }
  31. this.name = 'ydn.error.ArgumentException';
  32. };
  33. goog.inherits(ydn.error.ArgumentException, Error);
  34. /// FIXME: how come compiler strip out prototype name ?
  35. //
  36. ///** @override */
  37. //ydn.error.ArgumentException.prototype.name = 'ydn.ArgumentException';
  38. /**
  39. * Base class for custom error objects.
  40. * @param {*=} opt_msg The message associated with the error.
  41. * @constructor
  42. * @extends {Error}
  43. */
  44. ydn.error.NotSupportedException = function(opt_msg) {
  45. // Ensure there is a stack trace.
  46. if (Error.captureStackTrace) {
  47. Error.captureStackTrace(this, ydn.error.NotSupportedException);
  48. } else {
  49. this.stack = new Error().stack || '';
  50. }
  51. if (opt_msg) {
  52. this.message = String(opt_msg);
  53. }
  54. this.name = 'ydn.error.NotSupportedException';
  55. };
  56. goog.inherits(ydn.error.ArgumentException, Error);
  57. /** @override */
  58. ydn.error.NotSupportedException.prototype.name = 'ydn.error.NotSupportedException';
  59. /**
  60. * Base class for custom error objects.
  61. * @param {*=} opt_msg The message associated with the error.
  62. * @constructor
  63. * @extends {Error}
  64. */
  65. ydn.error.NotImplementedException = function(opt_msg) {
  66. // Ensure there is a stack trace.
  67. if (Error.captureStackTrace) {
  68. Error.captureStackTrace(this, ydn.error.NotImplementedException);
  69. } else {
  70. this.stack = new Error().stack || '';
  71. }
  72. if (opt_msg) {
  73. this.message = String(opt_msg);
  74. }
  75. this.name = 'ydn.error.NotImplementedException';
  76. };
  77. goog.inherits(ydn.error.NotImplementedException, Error);
  78. ///** @override */
  79. //ydn.error.NotImplementedException.prototype.name = 'ydn.NotImplementedException';
  80. /**
  81. * Base class for custom error objects.
  82. * @param {*=} opt_msg The message associated with the error.
  83. * @constructor
  84. * @extends {Error}
  85. */
  86. ydn.error.InternalError = function(opt_msg) {
  87. // Ensure there is a stack trace.
  88. if (Error.captureStackTrace) {
  89. Error.captureStackTrace(this, ydn.error.InternalError);
  90. } else {
  91. this.stack = new Error().stack || '';
  92. }
  93. if (opt_msg) {
  94. this.message = String(opt_msg);
  95. }
  96. this.name = 'ydn.error.InternalError';
  97. };
  98. goog.inherits(ydn.error.InternalError, Error);
  99. ydn.error.InternalError.prototype.name = 'ydn.InternalError';
  100. /**
  101. * Base class for custom error objects.
  102. * @param {*=} opt_msg The message associated with the error.
  103. * @constructor
  104. * @extends {Error}
  105. */
  106. ydn.error.ConstraintError = function(opt_msg) {
  107. // Ensure there is a stack trace.
  108. if (Error.captureStackTrace) {
  109. Error.captureStackTrace(this, ydn.error.ConstraintError);
  110. } else {
  111. this.stack = new Error().stack || '';
  112. }
  113. if (opt_msg) {
  114. this.message = String(opt_msg);
  115. }
  116. this.name = 'ydn.error.ConstraintError';
  117. };
  118. goog.inherits(ydn.error.ConstraintError, Error);
  119. ydn.error.ConstraintError.prototype.name = 'ydn.error.ConstraintError';
  120. /**
  121. * Base class for custom error objects.
  122. * @param {*=} opt_msg The message associated with the error.
  123. * @constructor
  124. * @extends {Error}
  125. */
  126. ydn.error.InvalidOperationException = function(opt_msg) {
  127. // Ensure there is a stack trace.
  128. if (Error.captureStackTrace) {
  129. Error.captureStackTrace(this, ydn.error.InvalidOperationException);
  130. } else {
  131. this.stack = new Error().stack || '';
  132. }
  133. if (opt_msg) {
  134. this.message = String(opt_msg);
  135. }
  136. this.name = 'ydn.error.InvalidOperationException';
  137. };
  138. goog.inherits(ydn.error.ArgumentException, Error);
  139. ///** @override */
  140. //ydn.error.InvalidOperationException.prototype.name = 'ydn.InvalidOperationException';
  141. /**
  142. * Base class for custom error objects.
  143. * @param {*=} opt_msg The message associated with the error.
  144. * @constructor
  145. * @extends {Error}
  146. */
  147. ydn.error.InvalidOperationError = function(opt_msg) {
  148. // Ensure there is a stack trace.
  149. if (Error.captureStackTrace) {
  150. Error.captureStackTrace(this, ydn.error.InvalidOperationError);
  151. } else {
  152. this.stack = new Error().stack || '';
  153. }
  154. if (opt_msg) {
  155. this.message = String(opt_msg);
  156. }
  157. this.name = 'ydn.error.InvalidOperationError';
  158. };
  159. goog.inherits(ydn.error.InvalidOperationError, Error);
  160. //
  161. ///** @override */
  162. //ydn.error.InvalidOperationError.prototype.name = 'ydn.InvalidOperationError';