feat: return detailed perfect corp api errors to frontend

This commit is contained in:
2026-09-23 01:57:00 +05:30
parent 55f2da59c2
commit ae85b84d61
+3 -2
View File
@@ -99,7 +99,8 @@ exports.analyzeImage = async (req, res) => {
taskFinished = true;
finalResult = pollResponse.data;
} else if (status === 'error' || status === 'failed') {
throw new Error(`AI Task failed with status: ${status}`);
console.error('Perfect Corp API Task Error Details:', JSON.stringify(pollResponse.data, null, 2));
throw new Error(`AI Task failed with status: ${status}. Details: ${JSON.stringify(pollResponse.data)}`);
} else {
console.log(`Polling... (status: ${status}, attempt: ${attempts})`);
}
@@ -131,6 +132,6 @@ exports.analyzeImage = async (req, res) => {
} catch (error) {
console.error('Error analyzing image:', error.response ? JSON.stringify(error.response.data) : error.message);
res.status(500).json({ error: 'Failed to analyze image' });
res.status(500).json({ error: error.message || 'Failed to analyze image' });
}
};