a zip code crypto-currency system good for red ONLY

error_classes.js 828B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. var resolve = require('./resolve');
  3. module.exports = {
  4. Validation: errorSubclass(ValidationError),
  5. MissingRef: errorSubclass(MissingRefError)
  6. };
  7. function ValidationError(errors) {
  8. this.message = 'validation failed';
  9. this.errors = errors;
  10. this.ajv = this.validation = true;
  11. }
  12. MissingRefError.message = function (baseId, ref) {
  13. return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
  14. };
  15. function MissingRefError(baseId, ref, message) {
  16. this.message = message || MissingRefError.message(baseId, ref);
  17. this.missingRef = resolve.url(baseId, ref);
  18. this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
  19. }
  20. function errorSubclass(Subclass) {
  21. Subclass.prototype = Object.create(Error.prototype);
  22. Subclass.prototype.constructor = Subclass;
  23. return Subclass;
  24. }