Skip to content

Commit d3899b6

Browse files
committed
Add expansion warnings events.
- Add 'relateive IRI after expansion' warning event. - Add 'invalid property expansion' warning event. - Update tests to check call counts.
1 parent c96bd59 commit d3899b6

File tree

3 files changed

+515
-126
lines changed

3 files changed

+515
-126
lines changed

lib/context.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
10781078
activeCtx,
10791079
options
10801080
});
1081-
10821081
}
10831082
if(expansionMapResult !== undefined) {
10841083
value = expansionMapResult;
@@ -1144,6 +1143,18 @@ function _expandIri(activeCtx, value, relativeTo, localCtx, defined, options) {
11441143
});
11451144
if(expandedResult !== undefined) {
11461145
value = expandedResult;
1146+
} else {
1147+
_handleEvent({
1148+
event: {
1149+
code: 'relative IRI after expansion',
1150+
level: 'warning',
1151+
message: 'Expansion resulted in a relative IRI.',
1152+
details: {
1153+
value
1154+
}
1155+
},
1156+
options
1157+
});
11471158
}
11481159
}
11491160

lib/expand.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,18 @@ async function _expandObject({
464464
expandedParent
465465
});
466466
if(expandedProperty === undefined) {
467+
_handleEvent({
468+
event: {
469+
code: 'invalid property expansion',
470+
level: 'warning',
471+
message: 'Invalid expansion for property.',
472+
details: {
473+
// FIXME: include expandedProperty before mapping
474+
property: key
475+
}
476+
},
477+
options
478+
});
467479
continue;
468480
}
469481
}

0 commit comments

Comments
 (0)