source: imaps-frontend/node_modules/ajv/lib/compile/error_classes.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 828 bytes
Line 
1'use strict';
2
3var resolve = require('./resolve');
4
5module.exports = {
6 Validation: errorSubclass(ValidationError),
7 MissingRef: errorSubclass(MissingRefError)
8};
9
10
11function ValidationError(errors) {
12 this.message = 'validation failed';
13 this.errors = errors;
14 this.ajv = this.validation = true;
15}
16
17
18MissingRefError.message = function (baseId, ref) {
19 return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
20};
21
22
23function MissingRefError(baseId, ref, message) {
24 this.message = message || MissingRefError.message(baseId, ref);
25 this.missingRef = resolve.url(baseId, ref);
26 this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
27}
28
29
30function errorSubclass(Subclass) {
31 Subclass.prototype = Object.create(Error.prototype);
32 Subclass.prototype.constructor = Subclass;
33 return Subclass;
34}
Note: See TracBrowser for help on using the repository browser.