SocketFi surfaces errors through a consistent SocketFiError interface on the client side and through the error.code field of a failed VerifyAuthResult on the server side. Understanding each error code lets you write precise error-handling logic — distinguishing between user-initiated cancellations, expired sessions, configuration mistakes, and genuine failures — rather than treating all errors the same way.
SocketFiError interface
All client-side errors conform to the following interface:
When a client SDK method throws, catch it and inspect error.code to determine the appropriate response:
Comprehensive error handling pattern
The following example shows how to handle every possible error code from both authenticate() and requestTransaction() in a production TypeScript application:
Client SDK error codes
These errors are thrown by authenticate(), requestTransaction(), and other client SDK methods.
Server SDK error codes
These codes appear in the error.code field of a VerifyAuthResult when verifyAuth() returns { valid: false }. Respond to all of them with an HTTP 401 Unauthorized.
Server-side error handling example
USER_CANCELLED and TRANSACTION_REJECTED are intentional user actions, not application errors. Do not log them as errors, do not display error modals, and do not retry automatically. Simply return your UI to a neutral state and let the user decide what to do next.