-
Notifications
You must be signed in to change notification settings - Fork 14
HTTP and Network Error structure refactor #2463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
giuliamorg92
merged 14 commits into
sdk-v3
from
2413-sdkv3---replicate-the-feature-in-sdkv3
Sep 23, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
56ba041
feat: refactor error handling in ThorError to provide specific error …
giuliamorg92 3030bc4
feat: new project key
giuliamorg92 c8c16a7
fix: mock commit
giuliamorg92 3c2be1c
feat: new HttpException and HttpNetworkException classes to represent…
giuliamorg92 a7aa15c
Merge branch 'sdk-v3' into 2413-sdkv3---replicate-the-feature-in-sdkv3
giuliamorg92 971a9f6
fix: revert issue in yarn lock merge
giuliamorg92 a4094ab
fix: deps
giuliamorg92 91390a5
Update packages/sdk/src/thor/thorest/accounts/methods/InspectClauses.ts
giuliamorg92 51ba815
fix: imports
giuliamorg92 e8781f1
fix: imports
giuliamorg92 cf83fc7
Update packages/sdk/src/thor/thorest/accounts/methods/RetrieveStorage…
giuliamorg92 4402cc7
fix: Avoid misclassifying JSON parse errors as network errors
giuliamorg92 cb9728a
fix: lint
giuliamorg92 356f6b5
Update packages/sdk/src/thor/thorest/accounts/methods/RetrieveStorage…
giuliamorg92 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { VeChainSDKError } from '@common/errors'; | ||
|
||
/** | ||
* Represents an HTTP error for non-200 responses. | ||
* | ||
* @remarks | ||
* This error class extends the `VeChainSDKError` and denotes HTTP errors encountered | ||
* when the server returns a non-200 status code (e.g., 400, 404, 500, etc.). | ||
* It includes additional information about the HTTP status code and response details. | ||
*/ | ||
class HttpException extends VeChainSDKError { | ||
/** | ||
* The [HTTP Status Code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status) | ||
* returned by the server. | ||
*/ | ||
readonly status: number; | ||
|
||
/** | ||
* The HTTP status text returned by the server. | ||
*/ | ||
readonly statusText: string; | ||
|
||
/** | ||
* The response body as text. | ||
*/ | ||
readonly responseBody: string; | ||
|
||
/** | ||
* The URL that was requested. | ||
*/ | ||
readonly url: string; | ||
|
||
/** | ||
* Constructs a new instance of the class. | ||
* | ||
* @param {string} fqn - The fully qualified name associated with the instance. | ||
* @param {string} message - The message describing the instance context or error. | ||
* @param {number} status - The HTTP status code. | ||
* @param {string} statusText - The HTTP status text. | ||
* @param {string} responseBody - The response body as text. | ||
* @param {string} url - The URL that was requested. | ||
* @param {Record<string, unknown>} [args] - Optional additional arguments related to the instance. | ||
* @param {Error} [cause] - Optional underlying error that caused the issue. | ||
*/ | ||
constructor( | ||
fqn: string, | ||
message: string, | ||
status: number, | ||
statusText: string, | ||
responseBody: string, | ||
url: string, | ||
args?: Record<string, unknown>, | ||
cause?: Error | ||
) { | ||
super(fqn, message, args, cause); | ||
this.status = status; | ||
this.statusText = statusText; | ||
this.responseBody = responseBody; | ||
this.url = url; | ||
} | ||
} | ||
|
||
export { HttpException }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { VeChainSDKError } from '@common/errors'; | ||
|
||
/** | ||
* Represents a network error for connection issues, timeouts, or no response. | ||
* | ||
* @remarks | ||
* This error class extends the `VeChainSDKError` and denotes network errors encountered | ||
* when there are connection issues, timeouts, or when no response is received from the server. | ||
* It includes additional information about the network error type and request details. | ||
*/ | ||
class HttpNetworkException extends VeChainSDKError { | ||
/** | ||
* The type of network error that occurred. | ||
*/ | ||
readonly networkErrorType: 'timeout' | 'connection' | 'no_response' | 'abort'; | ||
|
||
/** | ||
* The URL that was requested. | ||
*/ | ||
readonly url: string; | ||
|
||
/** | ||
* Constructs a new instance of the class. | ||
* | ||
* @param {string} fqn - The fully qualified name associated with the instance. | ||
* @param {string} message - The message describing the instance context or error. | ||
* @param {string} networkErrorType - The type of network error that occurred. | ||
* @param {string} url - The URL that was requested. | ||
* @param {Record<string, unknown>} [args] - Optional additional arguments related to the instance. | ||
* @param {Error} [cause] - Optional underlying error that caused the issue. | ||
*/ | ||
constructor( | ||
fqn: string, | ||
message: string, | ||
networkErrorType: 'timeout' | 'connection' | 'no_response' | 'abort', | ||
url: string, | ||
args?: Record<string, unknown>, | ||
cause?: Error | ||
) { | ||
super(fqn, message, args, cause); | ||
this.networkErrorType = networkErrorType; | ||
this.url = url; | ||
} | ||
} | ||
|
||
export { HttpNetworkException }; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
export * from './certificate'; | ||
export * from './signer'; | ||
export * from './thor-client'; | ||
export * from './thorest'; | ||
giuliamorg92 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export * from './thor-client/ThorClient'; | ||
export * from './thor-client/accounts'; | ||
export * from './thor-client/gas'; | ||
export * from './thor-client/model/accounts'; | ||
export * from './thor-client/model/nodes'; | ||
export * from './utils'; | ||
export * from './ws'; |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.