forked from paulhiggs/dvb-i-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonErrors.js
87 lines (80 loc) · 3.09 KB
/
CommonErrors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// CommonErrors.js
import { dvbi } from "./DVB-I_definitions.js";
import { tva } from "./TVA_definitions.js";
export const keys = {
k_InvalidValue: "invalid value",
k_InvalidTag: "invalid tag",
k_LengthError: "length error",
k_DuplicatedSynopsisLength: "duplicted synopsis length",
k_MissingSynopsisLength: "missing synopsis length",
k_InvalidKeywordType: "invalid keyword type",
k_ParentalGuidance: "parental guidance",
k_InvalidElement: "invalid element",
k_MissingElement: "missing element",
k_InvalidURL: "invalid URL",
k_UnspecifiedLanguage: "unspecified language",
k_InvalidLanguage: "invalid language",
k_InvalidRegion: "invalid region",
k_InvalidCountryCode: "invalid country code",
k_XSDValidation: "XSD validation",
};
import { WARNING } from "./ErrorList.js";
/**
* Add an error message when the a required element is not present
*
* @param {Object} errs Errors buffer
* @param {string} missingElement Name of the missing element
* @param {XMLnode} parentElement The element which should contain the missingElement
* @param {string} schemaLoctation The location in the schema of the element
* @param {string} errCode The error number to show in the log
*/
export var NoChildElement = (missingElement, parentElement, schemaLocation, errCode) => ({
code: errCode,
message: `${missingElement} element not specified for ${parentElement.name().elementize()}${schemaLocation ? " in " + schemaLocation : ""}`,
line: parentElement.line(),
});
/**
* Add an error message when the @href contains an invalid value
*
* @param {string} value The invalid value for the href attribute
* @param {XMLnode} element The element containing the @href attribute
* @param {string} loc The location of the element
* @param {Object} errs Errors buffer
* @param {string} errCode The error number to show in the log
*/
export var cg_InvalidHrefValue = (value, element, loc, errCode) => ({
code: errCode,
message: `invalid ${tva.a_href.attribute()}=${value.quote()} specified for ${element.name().elementize()} in ${loc}`,
line: element.line(),
key: "invalid href",
});
export var sl_InvalidHrefValue = (value, element, src, loc, errCode) => ({
code: errCode,
fragment: element,
line: element.line(),
message: `invalid ${dvbi.a_href.attribute()}=${value.quote()} specified for ${src} in ${loc}`,
key: "invalid href",
});
export var InvalidURL = (value, element, src, errCode) => ({
code: errCode,
fragment: element,
line: element.line(),
message: `invalid URL "${value}" specified for ${src.elementize()}`,
key: keys.k_InvalidURL,
});
export var DeprecatedElement = (what, when, errCode) => ({
type: WARNING,
code: errCode,
fragment: what,
line: what.line(),
message: `${what.name().elementize()} in ${what.parent().name().elementize()} is deprecated in ${when}`,
keys: "deprecated element",
});
export var DeprecatedAttribute = (what, when, errCode) => ({
type: WARNING,
code: errCode,
fragment: what.parent(),
line: what.parent().line(),
message: `${what.name().elementize(what.parent().name)} is deprecated in ${when}`,
keys: "deprecated attribute",
});