Skip to content

Commit

Permalink
Replace non-existed CourierHttpClientError with actual CourierError (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lkazberova committed Mar 29, 2024
1 parent 365095b commit aefbca7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -696,12 +696,12 @@ run();

This package tries to use the native `fetch` client to make requests or falls back to a polyfill if the client doesn't exist in the environment it's running in.

All network related promise rejections are not handled in any way. All successfully made requests that produce errors on the server side are resulting in promise rejections with custom `CourierHttpClientError` error type.
All network related promise rejections are not handled in any way. All successfully made requests that produce errors on the server side are resulting in promise rejections with custom `CourierError` error type.

`CourierHttpClientError` extends native `Error` interface with two extra properties:
`CourierError` extends native `Error` interface with two extra properties:

- `response`: this is the `fetch` response as is
- `data`: this is the parsed body of the response
- `statusCode`: this is the status code of the response
- `body`: this is the body of the response

```javascript
// Error handling example
Expand All @@ -714,7 +714,7 @@ try {
} catch (error) {
if (error instanceof CourierError) {
console.log("Failed to send with status code:", error.statusCode);
console.log("The Courier response is:", error.data);
console.log("The Courier body is:", error.body);
console.log("The error message is:", error.message);
} else {
console.log(
Expand Down

0 comments on commit aefbca7

Please sign in to comment.