Fix subtitle error handling to properly display validation errors

This commit is contained in:
DJP 2025-12-10 22:32:23 -05:00
parent 5dc665d818
commit c6167f33f0

View file

@ -149,7 +149,18 @@ export default function SubtitlesPage() {
toast.success('Subtitle processing started!');
} catch (err: any) {
toast.error(err.response?.data?.detail || 'Failed to start processing');
console.error('Subtitle processing error:', err);
// Handle validation errors (array of error objects)
if (err.response?.data?.detail && Array.isArray(err.response.data.detail)) {
const errorMessages = err.response.data.detail.map((e: any) => e.msg || JSON.stringify(e)).join(', ');
toast.error(`Validation error: ${errorMessages}`);
} else if (typeof err.response?.data?.detail === 'string') {
toast.error(err.response.data.detail);
} else {
toast.error('Failed to start processing');
}
setLoading(false);
}
};