ValidationError.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6. 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; }
  7. 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; }
  8. var ValidationError = function (_Error) {
  9. _inherits(ValidationError, _Error);
  10. function ValidationError(err, name) {
  11. var _ret;
  12. _classCallCheck(this, ValidationError);
  13. var _this = _possibleConstructorReturn(this, (ValidationError.__proto__ || Object.getPrototypeOf(ValidationError)).call(this, err));
  14. _this.err = err;
  15. _this.stack = false;
  16. _this.message = 'Validation Error\n\n' + String(name || '') + ' Invalid Options\n\n';
  17. err.forEach(function (msg) {
  18. _this.message += 'options' + String(msg.dataPath) + ' ' + String(msg.message) + '\n';
  19. });
  20. return _ret = _this, _possibleConstructorReturn(_this, _ret);
  21. }
  22. return ValidationError;
  23. }(Error);
  24. exports.default = ValidationError;