Skip to content

Commit e724f44

Browse files
committed
Include config id in invalid param error message
1 parent c8bf880 commit e724f44

6 files changed

+26
-14
lines changed

lib/preprocess/ParameterHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class ParameterHandler {
4848
value = values[0];
4949
} else if (values.length > 0) {
5050
if (values.some(subValue => !subValue.list)) {
51-
throw new ErrorResourcesContext(`Detected multiple values for parameter ${parameter.value}. RDF lists should be used for defining multiple values.`, {
51+
throw new ErrorResourcesContext(`Detected multiple values for parameter ${parameter.value} in ${configElement.value}. RDF lists should be used for defining multiple values.`, {
5252
arguments: values,
5353
});
5454
}

test/integration/instantiateResourceConfigComponent-test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,14 @@ describe('construction with component configs as Resource', () => {
126126

127127
it('instantiated with a config with all parameters with multiple values should throw', async() => {
128128
const config = objectLoader.createCompactedResource({
129+
'@id': 'ex:config',
129130
types: 'http://example.org/n3#Lexer',
130131
'http://example.org/n3#lineMode': [ '"A1"', '"A2"' ],
131132
'http://example.org/n3#n3': [ '"B1"', '"B2"' ],
132133
'http://example.org/n3#comments': [ '"C1"', '"C2"' ],
133134
});
134135
await expect(configConstructorPool.instantiate(config, settings)).rejects
135-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
136+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
136137
});
137138

138139
it('instantiated with a config with all parameters with multiple values as list', async() => {
@@ -241,13 +242,14 @@ describe('construction with component configs as Resource', () => {
241242

242243
it('instantiated with a config with all parameters as multiple non-list values should throw', async() => {
243244
const config = objectLoader.createCompactedResource({
245+
'@id': 'ex:config',
244246
types: 'http://example.org/n3#Lexer',
245247
'http://example.org/n3#lineMode': [ '"true"', '"false"' ],
246248
'http://example.org/n3#n3': [ '"true"', '"false"' ],
247249
'http://example.org/n3#comments': [ '"true"', '"false"' ],
248250
});
249251
await expect(configConstructorPool.instantiate(config, settings)).rejects
250-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
252+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
251253
});
252254

253255
it('instantiated with a config with all parameters as singular values as list', async() => {
@@ -318,13 +320,14 @@ describe('construction with component configs as Resource', () => {
318320

319321
it('instantiated with a config with all parameters with multiple values should throw', async() => {
320322
const config = objectLoader.createCompactedResource({
323+
'@id': 'ex:config',
321324
types: 'http://example.org/n3#Lexer',
322325
'http://example.org/n3#lineMode': [ '"A1"', '"A2"' ],
323326
'http://example.org/n3#n3': [ '"B1"', '"B2"' ],
324327
'http://example.org/n3#comments': [ '"C1"', '"C2"' ],
325328
});
326329
await expect(configConstructorPool.instantiate(config, settings)).rejects
327-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
330+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
328331
});
329332

330333
it('instantiated with a config with all parameters with multiple values as list should throw', async() => {
@@ -774,13 +777,14 @@ describe('construction with component configs as Resource', () => {
774777

775778
it('instantiated with a config with all parameters as multiple values in list', async() => {
776779
const config = objectLoader.createCompactedResource({
780+
'@id': 'ex:config',
777781
types: 'http://example.org/n3#Lexer',
778782
'http://example.org/n3#lineMode': [ '"true1"', '"true2"' ],
779783
'http://example.org/n3#n3': [ '"true"' ],
780784
'http://example.org/n3#comments': [ '"true"' ],
781785
});
782786
await expect(configConstructorPool.instantiate(config, settings)).rejects
783-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
787+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
784788
});
785789

786790
it('instantiated with a config with all parameters as singular value in RDF list', async() => {

test/integration/instantiateResourceConfigComponentMapped-test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,14 @@ describe('construction with mapped component configs as Resource', () => {
178178

179179
it('instantiated with a config with all parameters with multiple values as non-list', async() => {
180180
const config = objectLoader.createCompactedResource({
181+
'@id': 'ex:config',
181182
types: 'http://example.org/n3#Lexer',
182183
'http://example.org/n3#lineMode': [ '"A1"', '"A2"' ],
183184
'http://example.org/n3#n3': [ '"B1"', '"B2"' ],
184185
'http://example.org/n3#comments': [ '"C1"', '"C2"' ],
185186
});
186187
await expect(configConstructorPool.instantiate(config, settings)).rejects
187-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
188+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
188189
});
189190

190191
it('instantiated with a config with all parameters with multiple values as list', async() => {
@@ -290,13 +291,14 @@ describe('construction with mapped component configs as Resource', () => {
290291

291292
it('instantiated with a config with all parameters with multiple values as non-list', async() => {
292293
const config = objectLoader.createCompactedResource({
294+
'@id': 'ex:config',
293295
types: 'http://example.org/n3#Lexer',
294296
'http://example.org/n3#lineMode': [ '"A1"', '"A2"' ],
295297
'http://example.org/n3#n3': [ '"B1"', '"B2"' ],
296298
'http://example.org/n3#comments': [ '"C1"', '"C2"' ],
297299
});
298300
await expect(configConstructorPool.instantiate(config, settings)).rejects
299-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
301+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
300302
});
301303

302304
it('instantiated with a config with all parameters with multiple values as list', async() => {
@@ -443,13 +445,14 @@ describe('construction with mapped component configs as Resource', () => {
443445

444446
it('instantiated with a config with all parameters with multiple values as non-list', async() => {
445447
const config = objectLoader.createCompactedResource({
448+
'@id': 'ex:config',
446449
types: 'http://example.org/n3#Lexer',
447450
'http://example.org/n3#lineMode': [ '"A1"', '"A2"' ],
448451
'http://example.org/n3#n3': [ '"B1"', '"B2"' ],
449452
'http://example.org/n3#comments': [ '"C1"', '"C2"' ],
450453
});
451454
await expect(configConstructorPool.instantiate(config, settings)).rejects
452-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
455+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
453456
});
454457

455458
it('instantiated with a config with all parameters with multiple values as list', async() => {
@@ -1075,13 +1078,14 @@ describe('construction with mapped component configs as Resource', () => {
10751078

10761079
it('instantiated with a config with all parameters as multiple values in list', async() => {
10771080
const config = objectLoader.createCompactedResource({
1081+
'@id': 'ex:config',
10781082
types: 'http://example.org/n3#Lexer',
10791083
'http://example.org/n3#lineMode': [ '"true1"', '"true2"' ],
10801084
'http://example.org/n3#n3': [ '"true"' ],
10811085
'http://example.org/n3#comments': [ '"true"' ],
10821086
});
10831087
await expect(configConstructorPool.instantiate(config, settings)).rejects
1084-
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode. RDF lists should be used for defining multiple values.`);
1088+
.toThrowError(`Detected multiple values for parameter http://example.org/n3#lineMode in ex:config. RDF lists should be used for defining multiple values.`);
10851089
});
10861090

10871091
it('instantiated with a config with all parameters as singular value in RDF list', async() => {

test/unit/preprocess/ConfigPreprocessorComponent-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ describe('ConfigPreprocessorComponent', () => {
267267
});
268268
const expectedArgs = objectLoader.createCompactedResource({});
269269
expect(() => expectTransformOutput(config, expectedArgs))
270-
.toThrowError(`Detected multiple values for parameter ex:myComponentInstance#param1. RDF lists should be used for defining multiple values.`);
270+
.toThrowError(`Detected multiple values for parameter ex:myComponentInstance#param1 in ex:myComponentInstance. RDF lists should be used for defining multiple values.`);
271271
});
272272

273273
it('should handle one parameter with multiple values as list', () => {

test/unit/preprocess/ConfigPreprocessorComponentMapped-test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ describe('ConfigPreprocessorComponentMapped', () => {
187187
value: 'ex:param1',
188188
});
189189
const configElement = objectLoader.createCompactedResource({
190+
'@id': 'ex:config',
190191
'ex:param1': [
191192
'"A"',
192193
'"B"',
@@ -195,7 +196,7 @@ describe('ConfigPreprocessorComponentMapped', () => {
195196
const expected = objectLoader.createCompactedResource({});
196197
expect(() => expectOutputProperties(preprocessor
197198
.applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement, genericsContext), expected))
198-
.toThrowError(`Detected multiple values for parameter ex:param1. RDF lists should be used for defining multiple values.`);
199+
.toThrowError(`Detected multiple values for parameter ex:param1 in ex:config. RDF lists should be used for defining multiple values.`);
199200
});
200201

201202
it('should pass args with literal key and multiple values as list', () => {
@@ -903,11 +904,12 @@ describe('ConfigPreprocessorComponentMapped', () => {
903904
],
904905
});
905906
const configElement = objectLoader.createCompactedResource({
907+
'@id': 'ex:config',
906908
'ex:param1': [ '"VALUE1"', '"VALUE2"' ],
907909
});
908910
expect(() => preprocessor
909911
.applyConstructorArgumentsParameters(configRoot, constructorArgs, configElement, genericsContext))
910-
.toThrowError(`Detected multiple values for parameter ex:param1. RDF lists should be used for defining multiple values.`);
912+
.toThrowError(`Detected multiple values for parameter ex:param1 in ex:config. RDF lists should be used for defining multiple values.`);
911913
});
912914

913915
it('should pass args with one dynamic field with multiple values as list', () => {

test/unit/preprocess/ParameterHandler-test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ describe('ParameterHandler', () => {
6969

7070
it('should reject multiple set values', () => {
7171
configElement = objectLoader.createCompactedResource({
72+
'@id': 'ex:config',
7273
'ex:myParam': [
7374
'"A"',
7475
'"B"',
7576
'"C"',
7677
],
7778
});
7879
expect(() => handler.applyParameterValues(configRoot, param, configElement, genericsContext))
79-
.toThrowError(`Detected multiple values for parameter ex:myParam. RDF lists should be used for defining multiple values.`);
80+
.toThrowError(`Detected multiple values for parameter ex:myParam in ex:config. RDF lists should be used for defining multiple values.`);
8081
});
8182

8283
it('should handle list values', () => {
@@ -131,6 +132,7 @@ describe('ParameterHandler', () => {
131132

132133
it('should reject list and set values', () => {
133134
configElement = objectLoader.createCompactedResource({
135+
'@id': 'ex:config',
134136
'ex:myParam': [
135137
'"A"',
136138
{
@@ -142,7 +144,7 @@ describe('ParameterHandler', () => {
142144
],
143145
});
144146
expect(() => handler.applyParameterValues(configRoot, param, configElement, genericsContext))
145-
.toThrowError(`Detected multiple values for parameter ex:myParam. RDF lists should be used for defining multiple values.`);
147+
.toThrowError(`Detected multiple values for parameter ex:myParam in ex:config. RDF lists should be used for defining multiple values.`);
146148
});
147149
});
148150

0 commit comments

Comments
 (0)