Improve error handling for unavailable network shares
- Add OSError/PermissionError handling in browse endpoint - Return 503 status code when folders are temporarily unavailable - Display user-friendly error messages in the UI - Enhance error logging with exception type information Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1579,7 +1579,14 @@ async function browsePath(folderId, path, offset = 0, nocache = false) {
|
||||
{ headers: { 'Authorization': `Bearer ${token}` } }
|
||||
);
|
||||
|
||||
if (!response.ok) throw new Error('Failed to browse path');
|
||||
if (!response.ok) {
|
||||
let errorMsg = 'Failed to browse path';
|
||||
if (response.status === 503) {
|
||||
const errorData = await response.json().catch(() => ({}));
|
||||
errorMsg = errorData.detail || 'Folder is temporarily unavailable (network share not accessible)';
|
||||
}
|
||||
throw new Error(errorMsg);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
currentPath = data.current_path;
|
||||
@@ -1602,7 +1609,8 @@ async function browsePath(folderId, path, offset = 0, nocache = false) {
|
||||
saveLastBrowserPath(folderId, currentPath);
|
||||
} catch (error) {
|
||||
console.error('Error browsing path:', error);
|
||||
showToast(t('browser.error_loading'), 'error');
|
||||
const errorMsg = error.message || t('browser.error_loading');
|
||||
showToast(errorMsg, 'error');
|
||||
clearBrowserGrid();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user