Skip to content

Commit f94b13a

Browse files
Merge pull request #117 from reclaimprotocol/promptless/js-sdk-error-messages
docs: Document JS SDK error handling with specific error messages
2 parents ca83dfd + ed13828 commit f94b13a

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 0.1.0
22

3+
* 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
34
* 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
45
* **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.
56
* Added log event type documentation for inapp sdk and inapp react native sdk

content/docs/js-sdk/generating-proof.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,31 @@ onSuccess is called after the user has generated the proof, but you must [verify
5555
> [!TIP]
5656
> **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.
5757
58+
## Error Handling
59+
60+
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:
61+
62+
| Error Type | Message |
63+
| --- | --- |
64+
| **Proof Generation Failed** | Server-specific error details, or "Proof generation failed - timeout reached" |
65+
| **Verification Error** | Server-specific error details, or "An error occurred during the verification process" |
66+
| **Proof Not Verified** | "Proof verification failed - the generated proof could not be verified" |
67+
| **Proof Submission Failed** | Server-specific error details, or "Proof submission failed" |
68+
69+
Use these messages to show meaningful feedback to your users:
70+
71+
```javascript
72+
await reclaimProofRequest.startSession({
73+
onSuccess: (proofs) => {
74+
// handle successful verification
75+
},
76+
onError: (err) => {
77+
console.error('Verification failed:', err.message);
78+
// Display err.message to the user for specific error details
79+
}
80+
});
81+
```
82+
5883
## Example using `React`
5984
```javascript
6085
// hooks/useReclaim.js

0 commit comments

Comments
 (0)