Skip to main content

Error handling

With useConvertFile

The hook never throws inside the component — errors remain in the error state field, as instances of MarkpdfError (the same class as SDK base):
convert() also rejects the promise it returns, so you can capture it there if you prefer try/catch instead of reading error from the state:

With raw client (useMarkpdf)

The useMarkpdf() methods (convertFile, convertFromUrl, convertStream, pdfIndex, getJob) launch typed subclasses of MarkpdfError, just as in Node.js:
See the full error table of the base SDK — the same applies here because @markpdf/react re-exports the same classes.

Reusable error component

useConvertFile does not automatically retry. If you want retries with backoff at 429/5xx, use the base client (useMarkpdf()) with maxRetries — see Node.js SDK Error Handling — instead of useConvertFile, or implement your own retry around convert().