-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces the core classes for this library, namely: - `InruptClientError`, the superclass for all Inrupt client related errors, - `ClientHttpError`, the base class for HTTP errors Note that classes for specific HTTP errors (Unauthenticated, Not Found...) are not included yet, and will be added later. `ClientHttpError` extends the base `InruptClientError` by implementing two interfaces, `WithProblemDetails` and `WithErrorResponse`, respectively associated to their type guards `hasProblemDetails` and `hasErrorResponse`. Both the `.problemDetails` and `.response` accessors are marked as read-only, and immutability is enforced at runtime for libraries not using static analysis based on TS. The constructor of `ClientHttpError` takes in a response body and a subset of the native `Response` metadata, instead of taking a simple `Response` instance, because reading the `Response` body is an asynchronous operation, which isn't possible when building an object. It is expected that the parsing will be done by the caller in an async context, and the result will be passed to the `ClientHttpError` constructor, which is not the initial design. For the time being, I'm not doing any submodule exports (e.g. `@inrupt/solid-client-error/http`), but this is something we might eventually consider for tree-shaking.
- Loading branch information
Showing
21 changed files
with
1,141 additions
and
21 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,5 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
docs/api/source/ |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Solid JavaScript Error - solid-client-errors | ||
# Solid JavaScript Error - solid-client-error | ||
|
||
[![Contributor | ||
Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE-OF-CONDUCT.md) | ||
|
@@ -8,7 +8,7 @@ conduct](CODE-OF-CONDUCT.md). By participating, you are expected to uphold this | |
code. Please report unacceptable behavior to | ||
[[email protected]](mailto:[email protected]). | ||
|
||
`@inrupt/solid-client-errors` is a JavaScript library for handling [RFC9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457) on HTTP error responses. | ||
`@inrupt/solid-client-error` is a JavaScript library for handling [RFC9457 Problem Details](https://www.rfc-editor.org/rfc/rfc9457) on HTTP error responses. | ||
|
||
# Server support | ||
|
||
|
@@ -43,7 +43,7 @@ releases](https://nodejs.org/en/about/releases/), and support 18.x and 20.x. | |
For the latest stable version of solid-client-error: | ||
|
||
```bash | ||
npm install @inrupt/solid-client-errors | ||
npm install @inrupt/solid-client-error | ||
``` | ||
|
||
# Issues & Help | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// Copyright Inrupt Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal in | ||
// the Software without restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the | ||
// Software, and to permit persons to whom the Software is furnished to do so, | ||
// subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
import "@inrupt/jest-jsdom-polyfills"; |
Oops, something went wrong.