Skip to main content

Error Handling

Guide to handling errors in Report Flow API.

Common Error Codes

400 Bad Request

Invalid request parameters.

{
"statusCode": 400,
"message": ["designId must be a UUID"],
"error": "Bad Request"
}

Common causes:

  • Invalid UUID format
  • Missing required fields
  • Invalid file name characters

Solution: Validate input before sending request.

401 Unauthorized

Authentication failed.

{
"statusCode": 401,
"message": "Unauthorized",
"error": "Unauthorized"
}

Common causes:

  • Invalid AppKey or SecretKey
  • Workspace ID mismatch

Solution: Verify API keys and workspace ID.

404 Not Found

Resource not found.

{
"statusCode": 404,
"message": "Design not found",
"error": "Not Found"
}

Common causes:

  • Invalid design ID
  • File has expired

Solution: Verify resource ID is correct.

500 Internal Server Error

Server-side error.

{
"statusCode": 500,
"message": "Internal server error",
"error": "Internal Server Error"
}

Solution: Retry with exponential backoff. Contact support if it persists.

Error Handling Pattern

async function generatePDFWithErrorHandling(params) {
try {
return await generatePDF(params);
} catch (error) {
if (error.response) {
// Server responded with error
const { status, data } = error.response;

switch (status) {
case 400:
console.error('Validation error:', data.message);
throw new Error('Invalid parameters');

case 401:
console.error('Authentication error');
throw new Error('Check API keys');

case 404:
console.error('Resource not found');
throw new Error('Design not found');

case 500:
console.error('Server error, retrying...');
// Retry logic
return retryWithBackoff(() => generatePDF(params));

default:
throw error;
}
} else if (error.request) {
// Request made but no response
console.error('No response from server');
throw new Error('Network error');
} else {
// Request setup error
console.error('Request error:', error.message);
throw error;
}
}
}

Retry with Exponential Backoff

async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;

const delay = Math.pow(2, i) * 1000;
await sleep(delay);
}
}
}

Next Steps