You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  2. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  3. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4. function _extendableBuiltin(cls) {
  5. function ExtendableBuiltin() {
  6. cls.apply(this, arguments);
  7. }
  8. ExtendableBuiltin.prototype = Object.create(cls.prototype, {
  9. constructor: {
  10. value: cls,
  11. enumerable: false,
  12. writable: true,
  13. configurable: true
  14. }
  15. });
  16. if (Object.setPrototypeOf) {
  17. Object.setPrototypeOf(ExtendableBuiltin, cls);
  18. } else {
  19. ExtendableBuiltin.__proto__ = cls;
  20. }
  21. return ExtendableBuiltin;
  22. }
  23. var ExtendableError = function (_extendableBuiltin2) {
  24. _inherits(ExtendableError, _extendableBuiltin2);
  25. function ExtendableError() {
  26. var message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  27. _classCallCheck(this, ExtendableError);
  28. // extending Error is weird and does not propagate `message`
  29. var _this = _possibleConstructorReturn(this, (ExtendableError.__proto__ || Object.getPrototypeOf(ExtendableError)).call(this, message));
  30. Object.defineProperty(_this, 'message', {
  31. configurable: true,
  32. enumerable: false,
  33. value: message,
  34. writable: true
  35. });
  36. Object.defineProperty(_this, 'name', {
  37. configurable: true,
  38. enumerable: false,
  39. value: _this.constructor.name,
  40. writable: true
  41. });
  42. if (Error.hasOwnProperty('captureStackTrace')) {
  43. Error.captureStackTrace(_this, _this.constructor);
  44. return _possibleConstructorReturn(_this);
  45. }
  46. Object.defineProperty(_this, 'stack', {
  47. configurable: true,
  48. enumerable: false,
  49. value: new Error(message).stack,
  50. writable: true
  51. });
  52. return _this;
  53. }
  54. return ExtendableError;
  55. }(_extendableBuiltin(Error));
  56. export default ExtendableError;