feat: return detailed perfect corp api errors to frontend
This commit is contained in:
@@ -99,7 +99,8 @@ exports.analyzeImage = async (req, res) => {
|
|||||||
taskFinished = true;
|
taskFinished = true;
|
||||||
finalResult = pollResponse.data;
|
finalResult = pollResponse.data;
|
||||||
} else if (status === 'error' || status === 'failed') {
|
} 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 {
|
} else {
|
||||||
console.log(`Polling... (status: ${status}, attempt: ${attempts})`);
|
console.log(`Polling... (status: ${status}, attempt: ${attempts})`);
|
||||||
}
|
}
|
||||||
@@ -131,6 +132,6 @@ exports.analyzeImage = async (req, res) => {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error analyzing image:', error.response ? JSON.stringify(error.response.data) : error.message);
|
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' });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user