Skip to content

Commit

Permalink
Wrap errors encounted in case details retrieval
Browse files Browse the repository at this point in the history
Jira ticket: CAMS-461

Co-authored-by: Fritz Madden <[email protected]>
  • Loading branch information
2 people authored and amorrow-flexion committed Nov 29, 2024
1 parent 71d2bbc commit 173c7ed
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions backend/functions/lib/use-cases/case-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { CamsRole } from '../../../../common/src/cams/roles';
import { getCourtDivisionCodes } from '../../../../common/src/cams/users';
import { buildOfficeCode } from './offices/offices';
import { CaseAssignment } from '../../../../common/src/cams/assignments';
import { getCamsError } from '../common-errors/error-utilities';

const MODULE_NAME = 'CASE-MANAGEMENT-USE-CASE';

Expand Down Expand Up @@ -119,23 +120,31 @@ export default class CaseManagement {
applicationContext: ApplicationContext,
caseId: string,
): Promise<ResourceActions<CaseDetail>> {
const caseDetails = await this.casesGateway.getCaseDetail(applicationContext, caseId);
caseDetails.transfers = await this.casesRepo.getTransfers(caseId);
caseDetails.consolidation = await this.casesRepo.getConsolidation(caseId);
caseDetails.assignments = await this.getCaseAssignments(applicationContext, caseDetails);
caseDetails.officeName = this.officesGateway.getOfficeName(caseDetails.courtDivisionCode);
caseDetails.officeCode = buildOfficeCode(caseDetails.regionId, caseDetails.courtDivisionCode);
const _actions = getAction<CaseDetail>(applicationContext, caseDetails);
try {
const caseDetails = await this.casesGateway.getCaseDetail(applicationContext, caseId);
caseDetails.transfers = await this.casesRepo.getTransfers(caseId);
caseDetails.consolidation = await this.casesRepo.getConsolidation(caseId);
caseDetails.assignments = await this.getCaseAssignments(applicationContext, caseDetails);
caseDetails.officeName = this.officesGateway.getOfficeName(caseDetails.courtDivisionCode);
caseDetails.officeCode = buildOfficeCode(caseDetails.regionId, caseDetails.courtDivisionCode);
const _actions = getAction<CaseDetail>(applicationContext, caseDetails);

return { ...caseDetails, _actions };
return { ...caseDetails, _actions };
} catch (originalError) {
throw getCamsError(originalError, MODULE_NAME);
}
}

public async getCaseSummary(
applicationContext: ApplicationContext,
caseId: string,
): Promise<CaseSummary> {
const caseSummary = await this.casesGateway.getCaseSummary(applicationContext, caseId);
return caseSummary;
try {
const caseSummary = await this.casesGateway.getCaseSummary(applicationContext, caseId);
return caseSummary;
} catch (originalError) {
throw getCamsError(originalError, MODULE_NAME);
}
}

private async getCaseAssignments(
Expand Down

0 comments on commit 173c7ed

Please sign in to comment.