-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(chore) Add FetchError interface for more granular error annotation (#…
…1230) This PR adds a `FetchError` interface to the framework that can be used to annotate errors that occur during fetch requests. It also amends the `OpenmrsFetchError` class to implement the `FetchError` interface. Presently, the openmrsFetch hook throws a custom `OpenmrsFetchError` class that includes the response status code and status text if a request fails. This is not always the most helpful message, and it's not always clear what the underlying error was. The REST API returns a more useful message in the responseBody, and it would be preferable to show this message instead of the status code and status text. With this change, we can then use the FetchError interface further down the line in SWR hooks to annotate errors.
- Loading branch information
1 parent
a5b386a
commit d6283b0
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
packages/framework/esm-framework/docs/interfaces/FetchError.md
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[@openmrs/esm-framework](../API.md) / FetchError | ||
|
||
# Interface: FetchError | ||
|
||
## Implemented by | ||
|
||
- [`OpenmrsFetchError`](../classes/OpenmrsFetchError.md) | ||
|
||
## Table of contents | ||
|
||
### API Properties | ||
|
||
- [response](FetchError.md#response) | ||
- [responseBody](FetchError.md#responsebody) | ||
|
||
## API Properties | ||
|
||
### response | ||
|
||
• **response**: `Response` | ||
|
||
#### Defined in | ||
|
||
[packages/framework/esm-api/src/openmrs-fetch.ts:328](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L328) | ||
|
||
___ | ||
|
||
### responseBody | ||
|
||
• **responseBody**: ``null`` \| `ResponseBody` | ||
|
||
#### Defined in | ||
|
||
[packages/framework/esm-api/src/openmrs-fetch.ts:329](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L329) |