diff --git a/CHANGELOG.md b/CHANGELOG.md index d157abf..e731f42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/content/docs/js-sdk/generating-proof.mdx b/content/docs/js-sdk/generating-proof.mdx index 7f34247..3b9c159 100644 --- a/content/docs/js-sdk/generating-proof.mdx +++ b/content/docs/js-sdk/generating-proof.mdx @@ -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 + +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" | + +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