-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(open-payments): parse error objects, and return error codes (#484)
* chore(open-payments): parse error objects, and return error codes * chore(open-payments): add missing assertions, update tests * chore(open-payments): update README * chore(open-payments): add changeset * chore(open-payments): simplify assertion
- Loading branch information
Showing
7 changed files
with
190 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@interledger/open-payments': minor | ||
--- | ||
|
||
Adding functionality to parse error objects from Open Payments API responses, and expose new `code` field in `OpenPaymentsClientError`. |
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 |
---|---|---|
@@ -1,19 +1,22 @@ | ||
interface ErrorDetails { | ||
description: string | ||
status?: number | ||
code?: string | ||
validationErrors?: string[] | ||
} | ||
|
||
export class OpenPaymentsClientError extends Error { | ||
public description: string | ||
public validationErrors?: string[] | ||
public status?: number | ||
public code?: string | ||
|
||
constructor(message: string, args: ErrorDetails) { | ||
super(message) | ||
this.name = 'OpenPaymentsClientError' | ||
this.description = args.description | ||
this.status = args.status | ||
this.code = args.code | ||
this.validationErrors = args.validationErrors | ||
} | ||
} |
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
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