Handle errors
Catch and respond to errors from the API.
When a request fails, the SDK throws an error with the HTTP status and details from the API.
Catch errors
try {
await paperful.papers.get("00000000-0000-0000-0000-000000000000");
} catch (error: any) {
if (error.status === 404) {
console.log("Paper not found");
} else {
throw error;
}
} Common errors
| Status | Error | Description |
|---|---|---|
400 | Bad request | The request was invalid. |
401 | Unauthorized | The API key is missing or invalid. |
403 | Permission denied | The API key can't access this resource. |
404 | Not found | The resource doesn't exist. |
413 | Entity too large | The file is larger than your plan allows. |
415 | Unsupported media type | The file type isn't supported. |
429 | Too many requests | You've hit a rate limit. |