Error handling
SyncSnap flows can fail at several points: creating the job or while the server is waiting for completion (wait endpoint). The React and server SDKs surface these as thrown errors or via theonError callback.
React SDK: onError and error state
useSyncsnapJob (and therefore SyncsnapUploadButton) exposes:
- error —
Error | null; set when create or wait fails. - onError — optional callback called with the same
Error.
Common error cases
- Job creation fails — Network issue, invalid API key, or SyncSnap API error. User sees the error; they can retry (e.g. call
start()again). - Wait fails — Network or backend error while the wait request is in flight. Hook sets
errorand stops; callreset()thenstart()to retry. - Timeout — Job not completed within
waitTimeoutMs. The server may return 408; the hook setserror. User can start a new transfer. - Abort — If the user closes the dialog or you call
reset(), the wait request is aborted andonErroris not called.
Server SDK
Thesyncsnap server SDK throws when the SyncSnap API returns a non-2xx or an error body. Catch in your route and return an appropriate HTTP response:
getJob, the wait handler, and getDownloadUrl so the frontend receives a consistent error shape (e.g. { error: string }).
User-friendly messages
Map known error messages to user-facing copy if you want:getErrorMessage(error) in the UI.