Exception.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. import { CustomError } from 'ts-custom-error';
  15. /**
  16. * Custom Error class of type Exception.
  17. */
  18. var Exception = /** @class */ (function (_super) {
  19. __extends(Exception, _super);
  20. /**
  21. * Allows Exception to be constructed directly
  22. * with some message and prototype definition.
  23. */
  24. function Exception(message) {
  25. if (message === void 0) { message = undefined; }
  26. var _this = _super.call(this, message) || this;
  27. _this.message = message;
  28. return _this;
  29. }
  30. Exception.prototype.getKind = function () {
  31. var ex = this.constructor;
  32. return ex.kind;
  33. };
  34. /**
  35. * It's typed as string so it can be extended and overriden.
  36. */
  37. Exception.kind = 'Exception';
  38. return Exception;
  39. }(CustomError));
  40. export default Exception;