PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0
  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. * @fileoverview Utilities function for debug.
  14. *
  15. * NOTE: these code are stripped using compiler prefix feature.
  16. * See more detail in tools/strip_debug.txt file.
  17. *
  18. * @author kyawtun@yathit.com (Kyaw Tun)
  19. */
  20. goog.provide('ydn.debug.error.ArgumentException');
  21. goog.provide('ydn.debug.error.ConstraintError');
  22. goog.provide('ydn.debug.error.InternalError');
  23. goog.provide('ydn.debug.error.InvalidOperationException');
  24. goog.provide('ydn.debug.error.NotImplementedException');
  25. goog.provide('ydn.debug.error.NotSupportedException');
  26. goog.provide('ydn.debug.error.TypeError');
  27. goog.require('goog.debug.Error');
  28. /**
  29. * Base class for custom error objects.
  30. * @param {*=} opt_msg The message associated with the error.
  31. * @constructor
  32. * @extends {goog.debug.Error}
  33. */
  34. ydn.debug.error.ArgumentException = function(opt_msg) {
  35. goog.base(this, opt_msg);
  36. this.name = 'ydn.error.ArgumentException';
  37. };
  38. goog.inherits(ydn.debug.error.ArgumentException, goog.debug.Error);
  39. /**
  40. * Base class for custom error objects.
  41. * @param {*=} opt_msg The message associated with the error.
  42. * @constructor
  43. * @extends {goog.debug.Error}
  44. */
  45. ydn.debug.error.TypeError = function(opt_msg) {
  46. goog.base(this, opt_msg);
  47. this.name = 'ydn.error.TypeError';
  48. };
  49. goog.inherits(ydn.debug.error.TypeError, goog.debug.Error);
  50. /**
  51. * Base class for custom error objects.
  52. * @param {*=} opt_msg The message associated with the error.
  53. * @constructor
  54. * @extends {goog.debug.Error}
  55. */
  56. ydn.debug.error.NotSupportedException = function(opt_msg) {
  57. goog.base(this, opt_msg);
  58. this.name = 'ydn.error.NotSupportedException';
  59. };
  60. goog.inherits(ydn.debug.error.NotSupportedException, goog.debug.Error);
  61. /**
  62. * Base class for custom error objects.
  63. * @param {*=} opt_msg The message associated with the error.
  64. * @constructor
  65. * @extends {goog.debug.Error}
  66. */
  67. ydn.debug.error.NotImplementedException = function(opt_msg) {
  68. goog.base(this, opt_msg);
  69. this.name = 'ydn.error.NotImplementedException';
  70. };
  71. goog.inherits(ydn.debug.error.NotImplementedException, goog.debug.Error);
  72. /**
  73. * Base class for custom error objects.
  74. * @param {*=} opt_msg The message associated with the error.
  75. * @constructor
  76. * @extends {goog.debug.Error}
  77. */
  78. ydn.debug.error.InvalidOperationException = function(opt_msg) {
  79. goog.base(this, opt_msg);
  80. this.name = 'ydn.error.InvalidOperationException';
  81. };
  82. goog.inherits(ydn.debug.error.InvalidOperationException, goog.debug.Error);
  83. /**
  84. * Base class for custom error objects.
  85. * @param {*=} opt_msg The message associated with the error.
  86. * @constructor
  87. * @extends {Error}
  88. */
  89. ydn.debug.error.InternalError = function(opt_msg) {
  90. // Ensure there is a stack trace.
  91. if (Error.captureStackTrace) {
  92. Error.captureStackTrace(this, ydn.debug.error.InternalError);
  93. } else {
  94. this.stack = new Error().stack || '';
  95. }
  96. if (opt_msg) {
  97. this.message = String(opt_msg);
  98. }
  99. this.name = 'ydn.error.InternalError';
  100. };
  101. goog.inherits(ydn.debug.error.InternalError, Error);
  102. /**
  103. * Name of error.
  104. * @type {string}
  105. */
  106. ydn.debug.error.InternalError.prototype.name = 'ydn.error.InternalError';
  107. /**
  108. * Base class for custom error objects.
  109. * @param {*=} opt_msg The message associated with the error.
  110. * @constructor
  111. * @extends {Error}
  112. */
  113. ydn.debug.error.ConstraintError = function(opt_msg) {
  114. // Ensure there is a stack trace.
  115. if (Error.captureStackTrace) {
  116. Error.captureStackTrace(this, ydn.debug.error.ConstraintError);
  117. } else {
  118. this.stack = new Error().stack || '';
  119. }
  120. if (opt_msg) {
  121. this.message = String(opt_msg);
  122. }
  123. this.name = 'ydn.error.ConstraintError';
  124. };
  125. goog.inherits(ydn.debug.error.ConstraintError, Error);
  126. /**
  127. * Name of error.
  128. * @type {string}
  129. */
  130. ydn.debug.error.ConstraintError.prototype.name = 'ydn.error.ConstraintError';