removed timeout from upload request and improved error reporting
This commit is contained in:
parent
ef4080439b
commit
282f95dbc3
2 changed files with 32 additions and 1 deletions
|
|
@ -149,6 +149,7 @@ class ApiClient {
|
|||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
timeout: 0, // No timeout for video uploads (can be large files)
|
||||
onUploadProgress: onUploadProgress ? (progressEvent) => {
|
||||
if (progressEvent.total) {
|
||||
onUploadProgress({
|
||||
|
|
|
|||
|
|
@ -89,7 +89,37 @@ export function NewJob() {
|
|||
}, 3000);
|
||||
} catch (error) {
|
||||
console.error('Job creation failed:', error);
|
||||
toast.toastOnly.error('Failed to create job. Please check your file and try again.');
|
||||
|
||||
// Provide specific error messages based on error type
|
||||
const err = error as any;
|
||||
let errorMessage = 'Failed to create job. ';
|
||||
|
||||
if (err.code === 'ERR_NETWORK') {
|
||||
errorMessage += 'Network error - cannot reach server. Please check your connection.';
|
||||
} else if (err.code === 'ECONNABORTED' || err.message?.includes('timeout')) {
|
||||
errorMessage += 'Upload timeout. Your file may be too large or connection too slow.';
|
||||
} else if (err.response?.status === 413) {
|
||||
errorMessage += 'File is too large. Maximum file size is 500MB.';
|
||||
} else if (err.response?.status === 400) {
|
||||
const detail = err.response?.data?.detail;
|
||||
if (detail?.includes('video')) {
|
||||
errorMessage += 'Invalid file type. Please upload a video file (MP4, MOV, etc).';
|
||||
} else {
|
||||
errorMessage += detail || 'Invalid request data. Please check all fields.';
|
||||
}
|
||||
} else if (err.response?.status === 401) {
|
||||
errorMessage += 'Session expired. Please log in again.';
|
||||
} else if (err.response?.status === 403) {
|
||||
errorMessage += 'You do not have permission to create jobs.';
|
||||
} else if (err.response?.status === 500) {
|
||||
errorMessage += 'Server error. Please try again or contact support.';
|
||||
} else if (err.message) {
|
||||
errorMessage += err.message;
|
||||
} else {
|
||||
errorMessage += 'Unknown error. Please try again.';
|
||||
}
|
||||
|
||||
toast.toastOnly.error(errorMessage);
|
||||
setUploadProgress(0);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue