Skip to content

Commit daff7d4

Browse files
authored
Merge pull request #1093 from joshunrau/improve-error
provide validation issues when attempting to create an instrument record with invalid data
2 parents da5b99c + 2246fec commit daff7d4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

apps/api/src/instrument-records/instrument-records.service.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ export class InstrumentRecordsService {
6767

6868
const parseResult = instrument.validationSchema.safeParse(this.parseJson(rawData));
6969
if (!parseResult.success) {
70-
console.error(parseResult.error.issues);
71-
throw new UnprocessableEntityException(
72-
`Data received for record does not pass validation schema of instrument '${instrument.id}'`
73-
);
70+
throw new UnprocessableEntityException({
71+
error: 'Unprocessable Entity',
72+
issues: parseResult.error.issues,
73+
message: `Data received for record does not pass validation schema of instrument '${instrument.id}'`,
74+
statusCode: 422
75+
});
7476
}
7577

7678
return this.instrumentRecordModel.create({

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opendatacapture",
33
"type": "module",
4-
"version": "1.8.7",
4+
"version": "1.8.8",
55
"private": true,
66
"packageManager": "[email protected]",
77
"license": "Apache-2.0",

0 commit comments

Comments
 (0)