fix(wallets): throw typed InvalidSignerError when removeSigner API call fails#1899
fix(wallets): throw typed InvalidSignerError when removeSigner API call fails#1899devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Original prompt from Guille
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: 0c98887 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Reviews (1): Last reviewed commit: "fix(wallets): throw typed InvalidSignerE..." | Re-trigger Greptile |
|
Reviews (2): Last reviewed commit: "fix(wallets): fix TS2339 - safely access..." | Re-trigger Greptile |
| }); | ||
| throw new Error(`Failed to remove signer: ${JSON.stringify(response)}`); | ||
| const errorMessage = "message" in response ? response.message : JSON.stringify(response); | ||
| throw new InvalidSignerError(`Failed to remove signer: ${errorMessage}`, JSON.stringify(response)); |
There was a problem hiding this comment.
but why would this error be thrown? because a signer is invalid or something else?
Description
When
removeSignerreceives an error response from the API ("error" in response), it threwnew Error("Failed to remove signer: " + JSON.stringify(response))— a genericErrorthat consumers can't pattern-match by type, even though the response data was technically preserved in the stringified message.The
addSignermethod already throwsInvalidSignerErrorfor its API error case. This change makesremoveSignerconsistent by also throwingInvalidSignerErrorwith:response.messageas the error message (human-readable)details(machine-inspectable viaCrossmintSDKError.details)Same masking pattern fixed for OTP validation (#1886), get-status (#1896), export-signer (#1897), and addSigner chain failure (#1898).
Test plan
InvalidSignerErrorfor consistency withaddSignerPackage updates
@crossmint/wallets-sdk— patch changeset added (fix-removesigner-typed-error.md)Link to Devin session: https://crossmint.devinenterprise.com/sessions/7bd8230602444a8a94498384e0aac02d
Requested by: @xmint-guille