Skip to content

Commit 6fd4e49

Browse files
committed
Fixes error messages
1 parent f620cf4 commit 6fd4e49

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

packages/scenario/test/smoketests/child-vaccination.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Scenario extends BaseScenario {
102102
const currentPosition = this.getSelectedPositionalEvent();
103103

104104
if (currentPosition.eventType === 'END_OF_FORM') {
105-
throw 'todo';
105+
throw new Error('Cannot proceed. Reached the end of the form.');
106106
}
107107

108108
const events = this.getPositionalEvents();
@@ -138,7 +138,7 @@ class Scenario extends BaseScenario {
138138
const next = this.getNextEventPosition();
139139

140140
if (next.eventType === 'END_OF_FORM') {
141-
throw 'todo';
141+
throw new Error('Cannot proceed. Reached the end of the form.');
142142
}
143143

144144
return new JRTreeReference(next.node.currentState.reference);

packages/xpath/src/evaluator/expression/UnionExpressionEvaluator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ export class UnionExpressionEvaluator extends LocationPathExpressionEvaluator {
2323
const lhs = this.lhs.evaluate(context);
2424

2525
if (!(lhs instanceof LocationPathEvaluation)) {
26-
throw 'todo lhs not node-set result';
26+
throw new Error('Left-hand side expression did not evaluate to a node-set.');
2727
}
2828

2929
const rhs = this.rhs.evaluate(context);
3030

3131
if (!(rhs instanceof LocationPathEvaluation)) {
32-
throw 'todo rhs not node-set result';
32+
throw new Error('Right-hand side expression did not evaluate to a node-set.');
3333
}
3434

3535
const nodes = Array.from(new Set([...lhs.nodes, ...rhs.nodes]));

packages/xpath/src/evaluator/result/toXPathEvaluationResult.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ export const toXPathEvaluationResult = <T extends XPathNode>(
6767
case ANY_UNORDERED_NODE_TYPE:
6868
case FIRST_ORDERED_NODE_TYPE:
6969
if (nodes == null) {
70-
throw 'todo not a node-set';
70+
throw new Error('Expected a node-set for node iterator result, but received null.');
7171
}
7272

7373
return new NodeSetIteratorResult(domProvider, resultType, nodes);
7474

7575
case UNORDERED_NODE_SNAPSHOT_TYPE:
7676
case ORDERED_NODE_SNAPSHOT_TYPE:
7777
if (nodes == null) {
78-
throw 'todo not a node-set';
78+
throw new Error('Expected a node-set for node snapshot result, but received null.');
7979
}
8080

8181
return new NodeSetSnapshotResult(domProvider, resultType, nodes);

packages/xpath/src/functions/fn/node-set.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const count = new NumberFunction(
1111
const results = expression!.evaluate(context);
1212

1313
if (results.nodes == null) {
14-
throw 'todo not a node-set';
14+
throw new Error('Expected a node-set for count function, but received null.');
1515
}
1616

1717
return new Set(results.nodes).size;
@@ -64,7 +64,7 @@ export const localName = new StringFunction(
6464
const evaluated = expression?.evaluate(context) ?? context;
6565

6666
if (!(evaluated instanceof LocationPathEvaluation)) {
67-
throw 'todo not a node-set';
67+
throw new Error('Expected a node-set for local-name function, but received an invalid type.');
6868
}
6969

7070
const node = evaluated.first()?.value;
@@ -95,7 +95,7 @@ export const name = new StringFunction(
9595
const evaluated = expression?.evaluate(context) ?? context;
9696

9797
if (!(evaluated instanceof LocationPathEvaluation)) {
98-
throw 'todo not a node-set';
98+
throw new Error('Expected a node-set for name function, but received an invalid type.');
9999
}
100100

101101
const node = evaluated.first()?.value;
@@ -125,7 +125,7 @@ export const namespaceURI = new StringFunction(
125125
const evaluated = expression?.evaluate(context) ?? context;
126126

127127
if (!(evaluated instanceof LocationPathEvaluation)) {
128-
throw 'todo not a node-set';
128+
throw new Error('Expected a node-set for namespace-uri function, but received an invalid type.');
129129
}
130130

131131
const node = evaluated.first()?.value;

packages/xpath/src/functions/xforms/boolean.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export const weightedChecklist = new BooleanFunction(
7878
const weightExpression = expressions[i + 1];
7979

8080
if (weightExpression == null) {
81-
throw 'todo';
81+
throw new Error('The weighted-checklist function must be given an even number of arguments.');
8282
}
8383

8484
const results = expression.evaluate(context).values();

packages/xpath/src/functions/xforms/datetime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const evaluateDateTime = <T extends XPathNode>(
239239
}
240240

241241
default:
242-
throw 'todo';
242+
throw new Error('Expected a NUMBER or STRING evaluation type for date-time conversion, but received an invalid type.');
243243
}
244244
};
245245

packages/xpath/src/functions/xforms/node-set.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const countNonEmpty = new NumberFunction(
1717
const results = expression!.evaluate(context);
1818

1919
if (results.type !== 'NODE') {
20-
throw 'todo';
20+
throw new Error('Expected a node-set for count-non-empty function, but received an invalid type.');
2121
}
2222

2323
let result = 0;
@@ -252,7 +252,7 @@ export const once = new StringFunction(
252252
const [contextNode] = context.contextNodes;
253253

254254
if (contextNode == null) {
255-
throw 'todo once no context';
255+
throw new Error('No context node available for the once function.');
256256
}
257257

258258
const string = context.domProvider.getNodeValue(contextNode);
@@ -324,7 +324,7 @@ export const position = new NumberFunction(
324324
}
325325

326326
if (next != null) {
327-
throw 'todo enforce single node(?)';
327+
throw new Error('Expected a single node for position function, but multiple nodes were provided.');
328328
}
329329

330330
const { domProvider } = context;

packages/xpath/src/functions/xforms/string.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export const uuid = new StringFunction(
248248
const outputLength = lengthExpression.evaluate(context).toNumber();
249249

250250
if (Number.isNaN(outputLength)) {
251-
throw 'todo';
251+
throw new Error('Expected a valid number for the UUID length, but received NaN.');
252252
}
253253

254254
while (result.length < outputLength) {

0 commit comments

Comments
 (0)