main
Last change
on this file since d565449 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 |
|
---|
3 | var resolve = require('./resolve');
|
---|
4 |
|
---|
5 | module.exports = {
|
---|
6 | Validation: errorSubclass(ValidationError),
|
---|
7 | MissingRef: errorSubclass(MissingRefError)
|
---|
8 | };
|
---|
9 |
|
---|
10 |
|
---|
11 | function ValidationError(errors) {
|
---|
12 | this.message = 'validation failed';
|
---|
13 | this.errors = errors;
|
---|
14 | this.ajv = this.validation = true;
|
---|
15 | }
|
---|
16 |
|
---|
17 |
|
---|
18 | MissingRefError.message = function (baseId, ref) {
|
---|
19 | return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
|
---|
20 | };
|
---|
21 |
|
---|
22 |
|
---|
23 | function 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 |
|
---|
30 | function 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.