-
Notifications
You must be signed in to change notification settings - Fork 13
docs: Document JS SDK error handling with specific error messages #117
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| ## 0.1.0 | ||
|
|
||
| * JS SDK: `onError` callback now provides specific error messages indicating what went wrong during verification (proof generation failed, verification error, proof not verified, or proof submission failed) instead of generic errors | ||
| * Added EU region support documentation for JS SDK - use `https://eu.portal.reclaimprotocol.org` as `customSharePageUrl` to automatically route API requests to the EU backend | ||
| * **JS SDK**: When using a regional portal (any `customSharePageUrl` other than `share.reclaimprotocol.org` or `portal.reclaimprotocol.org`), you must now set a callback URL using `setAppCallbackUrl()`. The SDK throws a `CallbackUrlRequiredError` if missing. | ||
| * Added log event type documentation for inapp sdk and inapp react native sdk | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,31 @@ onSuccess is called after the user has generated the proof, but you must [verify | |
| > [!TIP] | ||
| > **Best Practice:** When using `setAppCallbackUrl` and/or `setCancelCallbackUrl`, your backend receives the proof or cancellation details directly. We recommend your backend notifies the frontend (e.g. via WebSockets, SSE, or polling) to stop the verification process and handle the appropriate success/failure action. Do not rely completely on `startSession` callbacks on the frontend when using these backend callbacks. | ||
|
|
||
| ## Error Handling | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Citation: Error types and messages based on changes in |
||
|
|
||
| The `onError` callback receives an error object with a `message` property describing what went wrong. The SDK returns specific error messages based on the failure type: | ||
|
|
||
| | Error Type | Message | | ||
| | --- | --- | | ||
| | **Proof Generation Failed** | Server-specific error details, or "Proof generation failed - timeout reached" | | ||
| | **Verification Error** | Server-specific error details, or "An error occurred during the verification process" | | ||
| | **Proof Not Verified** | "Proof verification failed - the generated proof could not be verified" | | ||
| | **Proof Submission Failed** | Server-specific error details, or "Proof submission failed" | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Citation: Updated the |
||
|
|
||
| Use these messages to show meaningful feedback to your users: | ||
|
|
||
| ```javascript | ||
| await reclaimProofRequest.startSession({ | ||
| onSuccess: (proofs) => { | ||
| // handle successful verification | ||
| }, | ||
| onError: (err) => { | ||
| console.error('Verification failed:', err.message); | ||
| // Display err.message to the user for specific error details | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| ## Example using `React` | ||
| ```javascript | ||
| // hooks/useReclaim.js | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Citation: Documents PR #80 which enhances error handling by propagating contextual error messages from API responses through the
onErrorcallback instead of generic fallbacks.View source