PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/js/ydn/error.js

https://bitbucket.org/floydpink/ydn-base
JavaScript | 194 lines | 92 code | 42 blank | 60 comment | 28 complexity | ca71d6b674dcfb3fb72ce911f6eb342c MD5 | raw file
  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.ConstrainError');
  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. };
  32. goog.inherits(ydn.error.ArgumentException, Error);
  33. /** @override */
  34. ydn.error.ArgumentException.prototype.name = 'ydn.ArgumentException';
  35. /**
  36. * Base class for custom error objects.
  37. * @param {*=} opt_msg The message associated with the error.
  38. * @constructor
  39. * @extends {Error}
  40. */
  41. ydn.error.NotSupportedException = function(opt_msg) {
  42. // Ensure there is a stack trace.
  43. if (Error.captureStackTrace) {
  44. Error.captureStackTrace(this, ydn.error.NotSupportedException);
  45. } else {
  46. this.stack = new Error().stack || '';
  47. }
  48. if (opt_msg) {
  49. this.message = String(opt_msg);
  50. }
  51. };
  52. goog.inherits(ydn.error.ArgumentException, Error);
  53. /** @override */
  54. ydn.error.NotSupportedException.prototype.name = 'ydn.NotSupportedException';
  55. /**
  56. * Base class for custom error objects.
  57. * @param {*=} opt_msg The message associated with the error.
  58. * @constructor
  59. * @extends {Error}
  60. */
  61. ydn.error.NotImplementedException = function(opt_msg) {
  62. // Ensure there is a stack trace.
  63. if (Error.captureStackTrace) {
  64. Error.captureStackTrace(this, ydn.error.NotImplementedException);
  65. } else {
  66. this.stack = new Error().stack || '';
  67. }
  68. if (opt_msg) {
  69. this.message = String(opt_msg);
  70. }
  71. };
  72. goog.inherits(ydn.error.NotImplementedException, Error);
  73. /** @override */
  74. ydn.error.NotImplementedException.prototype.name = 'ydn.NotImplementedException';
  75. /**
  76. * Base class for custom error objects.
  77. * @param {*=} opt_msg The message associated with the error.
  78. * @constructor
  79. * @extends {Error}
  80. */
  81. ydn.error.InternalError = function(opt_msg) {
  82. // Ensure there is a stack trace.
  83. if (Error.captureStackTrace) {
  84. Error.captureStackTrace(this, ydn.error.InternalError);
  85. } else {
  86. this.stack = new Error().stack || '';
  87. }
  88. if (opt_msg) {
  89. this.message = String(opt_msg);
  90. }
  91. };
  92. goog.inherits(ydn.error.InternalError, Error);
  93. ydn.error.InternalError.prototype.name = 'ydn.InternalError';
  94. /**
  95. * Base class for custom error objects.
  96. * @param {*=} opt_msg The message associated with the error.
  97. * @constructor
  98. * @extends {Error}
  99. */
  100. ydn.error.ConstrainError = function(opt_msg) {
  101. // Ensure there is a stack trace.
  102. if (Error.captureStackTrace) {
  103. Error.captureStackTrace(this, ydn.error.ConstrainError);
  104. } else {
  105. this.stack = new Error().stack || '';
  106. }
  107. if (opt_msg) {
  108. this.message = String(opt_msg);
  109. }
  110. };
  111. goog.inherits(ydn.error.ConstrainError, Error);
  112. ydn.error.ConstrainError.prototype.name = 'ydn.ConstrainError';
  113. /**
  114. * Base class for custom error objects.
  115. * @param {*=} opt_msg The message associated with the error.
  116. * @constructor
  117. * @extends {Error}
  118. */
  119. ydn.error.InvalidOperationException = function(opt_msg) {
  120. // Ensure there is a stack trace.
  121. if (Error.captureStackTrace) {
  122. Error.captureStackTrace(this, ydn.error.InvalidOperationException);
  123. } else {
  124. this.stack = new Error().stack || '';
  125. }
  126. if (opt_msg) {
  127. this.message = String(opt_msg);
  128. }
  129. };
  130. goog.inherits(ydn.error.ArgumentException, Error);
  131. /** @override */
  132. ydn.error.InvalidOperationException.prototype.name = 'ydn.InvalidOperationException';
  133. /**
  134. * Base class for custom error objects.
  135. * @param {*=} opt_msg The message associated with the error.
  136. * @constructor
  137. * @extends {Error}
  138. */
  139. ydn.error.InvalidOperationError = function(opt_msg) {
  140. // Ensure there is a stack trace.
  141. if (Error.captureStackTrace) {
  142. Error.captureStackTrace(this, ydn.error.InvalidOperationError);
  143. } else {
  144. this.stack = new Error().stack || '';
  145. }
  146. if (opt_msg) {
  147. this.message = String(opt_msg);
  148. }
  149. };
  150. goog.inherits(ydn.error.InvalidOperationError, Error);
  151. /** @override */
  152. ydn.error.InvalidOperationError.prototype.name = 'ydn.InvalidOperationError';