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:
@@ -254,8 +254,15 @@ async def browse(
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
except FileNotFoundError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
except (OSError, PermissionError) as e:
|
||||
# Network share unavailable or access denied
|
||||
logger.warning(f"Folder temporarily unavailable: {e}")
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
detail=f"Folder is temporarily unavailable. It may be a network share that is not accessible at the moment."
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error browsing directory: {e}")
|
||||
logger.error(f"Error browsing directory (type: {type(e).__name__}): {e}")
|
||||
raise HTTPException(status_code=500, detail="Failed to browse directory")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user