File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
apps/api/src/instrument-records Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import type {
1111 LinearRegressionResults ,
1212 UploadInstrumentRecordsData
1313} from '@opendatacapture/schemas/instrument-records' ;
14- import type { InstrumentRecordModel , Prisma , SessionModel } from '@prisma/generated-client' ;
14+ import { type InstrumentRecordModel , Prisma , type SessionModel } from '@prisma/generated-client' ;
1515import { isNumber , pickBy } from 'lodash-es' ;
1616
1717import { accessibleQuery } from '@/ability/ability.utils' ;
@@ -342,7 +342,18 @@ export class InstrumentRecordsService {
342342 const addedSubject : CreateSubjectDto = {
343343 id : subjectId
344344 } ;
345- await this . subjectsService . create ( addedSubject ) ;
345+ try {
346+ await this . subjectsService . create ( addedSubject ) ;
347+ } catch ( prismaError ) {
348+ if ( prismaError instanceof Prisma . PrismaClientKnownRequestError ) {
349+ // The .code property can be accessed in a type-safe manner
350+ // eslint-disable-next-line max-depth
351+ if ( prismaError . code === 'P2002' ) {
352+ console . error ( prismaError ) ;
353+ }
354+ }
355+ throw prismaError ;
356+ }
346357 } else {
347358 throw exception ;
348359 }
You can’t perform that action at this time.
0 commit comments