Skip to content

Commit

Permalink
Fix error handling in 'IGs' page
Browse files Browse the repository at this point in the history
  • Loading branch information
qligier committed Jan 5, 2024
1 parent 712f0cc commit bf16434
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion matchbox-frontend/src/app/igs/igs.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ <h3>Install an ImplementationGuide</h3>
<div *ngIf="errorMessage" class="white-block logs">
<h2>Result of the last operation</h2>

<app-operation-outcome [operationOutcome]="operationOutcome" [title]="errorMessage"></app-operation-outcome>
<app-operation-result *ngIf="operationResult" [operationResult]="operationResult"></app-operation-result>
</div>
33 changes: 25 additions & 8 deletions matchbox-frontend/src/app/igs/igs.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FhirConfigService } from '../fhirConfig.service';
import { UntypedFormControl, Validators } from '@angular/forms';
import FhirClient from 'fhir-kit-client';
import { FhirPathService } from '../fhirpath.service';
import {OperationResult} from "../util/operation-result";

@Component({
selector: 'app-igs',
Expand All @@ -20,7 +21,7 @@ export class IgsComponent {
client: FhirClient;
igs: fhir.r4.ImplementationGuide[];
errorMessage: string;
operationOutcome: fhir.r4.OperationOutcome;
operationResult: OperationResult | null = null;

query = {
_sort: 'title',
Expand Down Expand Up @@ -51,7 +52,11 @@ export class IgsComponent {
})
.catch((error) => {
this.errorMessage = 'Error accessing FHIR server';
this.operationOutcome = error.response.data;
if (error.response?.data) {
this.operationResult = OperationResult.fromOperationOutcome(error.response.data);
} else {
this.operationResult = OperationResult.fromMatchboxError(error.message);
}
});
this.update = false;
}
Expand Down Expand Up @@ -112,12 +117,16 @@ export class IgsComponent {
})
.then((response) => {
this.errorMessage = 'Created Implementation Guide ' + this.addPackageId.value;
this.operationOutcome = response as fhir.r4.OperationOutcome;
this.operationResult = OperationResult.fromOperationOutcome(response as fhir.r4.OperationOutcome);
this.search();
})
.catch((error) => {
this.errorMessage = 'Error creating Implementation Guide ' + this.addPackageId.value;
this.operationOutcome = error.response.data;
if (error.response?.data) {
this.operationResult = OperationResult.fromOperationOutcome(error.response.data);
} else {
this.operationResult = OperationResult.fromMatchboxError(error.message);
}
this.update = false;
});
}
Expand All @@ -144,12 +153,16 @@ export class IgsComponent {
})
.then((response) => {
this.errorMessage = 'Updated Implementation Guide ' + this.selection.packageId;
this.operationOutcome = response as fhir.r4.OperationOutcome;
this.operationResult = OperationResult.fromOperationOutcome(response as fhir.r4.OperationOutcome);
this.search();
})
.catch((error) => {
this.errorMessage = 'Error updating Implementation Guide ' + this.selection.packageId;
this.operationOutcome = error.response.data;
if (error.response?.data) {
this.operationResult = OperationResult.fromOperationOutcome(error.response.data);
} else {
this.operationResult = OperationResult.fromMatchboxError(error.message);
}
this.update = false;
});
}
Expand All @@ -171,12 +184,16 @@ export class IgsComponent {
})
.then((response) => {
this.errorMessage = 'Deleted Implementation Guide Resource ' + this.selection.packageId;
this.operationOutcome = response as fhir.r4.OperationOutcome;
this.operationResult = OperationResult.fromOperationOutcome(response as fhir.r4.OperationOutcome);
this.search();
})
.catch((error) => {
this.errorMessage = 'Error deleting Implementation Guide ' + this.selection.packageId;
this.operationOutcome = error.response.data;
if (error.response?.data) {
this.operationResult = OperationResult.fromOperationOutcome(error.response.data);
} else {
this.operationResult = OperationResult.fromMatchboxError(error.message);
}
this.update = false;
});
}
Expand Down

0 comments on commit bf16434

Please sign in to comment.