Skip to content

Commit 6fcfff7

Browse files
committed
Catch unfound entities when fetching by file number
1 parent 3d8d4cb commit 6fcfff7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

services/apps/alcs/src/alcs/compliance-and-enforcement/compliance-and-enforcement.service.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import { ComplianceAndEnforcement } from './compliance-and-enforcement.entity';
55
import { ComplianceAndEnforcementDto, UpdateComplianceAndEnforcementDto } from './compliance-and-enforcement.dto';
66
import { InjectMapper } from 'automapper-nestjs';
77
import { Mapper } from 'automapper-core';
8-
import { ServiceConflictException } from '../../../../../libs/common/src/exceptions/base.exception';
8+
import {
9+
ServiceConflictException,
10+
ServiceNotFoundException,
11+
} from '../../../../../libs/common/src/exceptions/base.exception';
912

1013
@Injectable()
1114
export class ComplianceAndEnforcementService {
@@ -30,6 +33,11 @@ export class ComplianceAndEnforcementService {
3033
fileNumber: fileNumber,
3134
},
3235
});
36+
37+
if (entity === null) {
38+
throw new ServiceNotFoundException('A C&E file with this file number does not exist.');
39+
}
40+
3341
return this.mapper.map(entity, ComplianceAndEnforcement, ComplianceAndEnforcementDto);
3442
}
3543

0 commit comments

Comments
 (0)