Created
December 7, 2025 22:06
-
-
Save trikitrok/8dfc480b9a379c38d2cfcb112350069f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WithErrorHandlingCompanyApi implements CompanyApi { | |
| constructor(private readonly decoratedApi: CompanyApi) { | |
| } | |
| async open(claim: Claim): Promise<OpeningResult> { | |
| try { | |
| return await this.decoratedApi.open(claim); | |
| } catch (e) { | |
| if (e instanceof CannotRetrieveTokenError) { | |
| return OpeningResult.failed(claim, 'Acme API: failure retrieving token'); | |
| } | |
| if (e instanceof CannotGetCausesError) { | |
| return OpeningResult.failed(claim, 'Acme API: failure getting claim causes'); | |
| } | |
| if (e instanceof CannotOpenClaimError) { | |
| return OpeningResult.failed( | |
| claim, `Acme API: cannot open claim ${claim.id()}` | |
| ); | |
| } | |
| if (e instanceof CannotFindMatchingCauseError) { | |
| return OpeningResult.failed( | |
| claim, `Acme API: cannot find cause for claim ${claim.id()}` | |
| ); | |
| } | |
| return OpeningResult.failed( | |
| claim, `Acme API: ${e.message}` | |
| ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment