Skip to content

Commit

Permalink
Improve error messages about datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Sep 19, 2023
1 parent 30664d1 commit 91bf705
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/model/query/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const createOrMerge = (name, form, fields) => async ({ one, Actees, Datasets, Pr
let dsPropertyFields = fields.filter((field) => (field.propertyName));
// Step 2: Check for invalid property names
if (dsPropertyFields.filter((field) => !validatePropertyName(field.propertyName)).length > 0)
throw Problem.user.invalidEntityForm({ reason: 'Invalid Dataset property.' });
throw Problem.user.invalidEntityForm({ reason: 'Invalid entity property name.' });
// Step 3: Build Form Field frames to handle dataset property field insertion
dsPropertyFields = dsPropertyFields.map((field) => new Form.Field(field, { propertyName: field.propertyName, schemaId, formDefId }));

Expand All @@ -110,7 +110,7 @@ const createOrMerge = (name, form, fields) => async ({ one, Actees, Datasets, Pr
const result = await one(_createOrMerge(partial, dsPropertyFields, acteeId))
.catch(error => {
if (error.constraint === 'ds_property_fields_dspropertyid_formdefid_unique') {
throw Problem.user.invalidEntityForm({ reason: 'Multiple Form Fields cannot be saved to a single Dataset Property.' });
throw Problem.user.invalidEntityForm({ reason: 'Multiple Form Fields cannot be saved to a single property.' });
}
throw error;
});
Expand Down
8 changes: 4 additions & 4 deletions test/integration/api/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2119,7 +2119,7 @@ describe('datasets and entities', () => {
.expect(400)
.then(({ body }) => {
body.code.should.equal(400.25);
body.details.reason.should.equal('Invalid Dataset property.');
body.details.reason.should.equal('Invalid entity property name.');
}))));

it('should return a Problem if the savetos reference invalid properties (extra whitespace)', testService((service) =>
Expand All @@ -2130,7 +2130,7 @@ describe('datasets and entities', () => {
.expect(400)
.then(({ body }) => {
body.code.should.equal(400.25);
body.details.reason.should.equal('Invalid Dataset property.');
body.details.reason.should.equal('Invalid entity property name.');
}))));

it('should return the created form upon success', testService((service) =>
Expand Down Expand Up @@ -2190,7 +2190,7 @@ describe('datasets and entities', () => {
.expect(400)
.then(({ body }) => {
body.code.should.be.eql(400.25);
body.message.should.be.eql('The entity definition within the form is invalid. Multiple Form Fields cannot be saved to a single Dataset Property.');
body.message.should.be.eql('The entity definition within the form is invalid. Multiple Form Fields cannot be saved to a single property.');
}));
}));

Expand Down Expand Up @@ -2377,7 +2377,7 @@ describe('datasets and entities', () => {
.expect(400)
.then(({ body }) => {
body.code.should.equal(400.25);
body.details.reason.should.equal('Invalid Dataset property.');
body.details.reason.should.equal('Invalid entity property name.');
}));
}));
});
Expand Down

0 comments on commit 91bf705

Please sign in to comment.