Fix subtitle error handling to properly display validation errors
This commit is contained in:
parent
5dc665d818
commit
c6167f33f0
1 changed files with 12 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue