{"record":{"id":"a425fa2bc4a80d9d","repo":"HKUDS/DeepTutor","slug":"exception-message","errorCode":null,"errorMessage":"{exception message}","messagePattern":"\\{exception message\\}","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"deeptutor/api/routers/notebook.py","lineNumber":197,"sourceCode":"    \"\"\"Health check\"\"\"\n    return {\"status\": \"healthy\", \"service\": \"notebook\"}\n\n\n@router.get(\"/list\")\nasync def list_notebooks():\n    \"\"\"\n    Get all notebook list\n\n    Returns:\n        Notebook list (includes summary information)\n    \"\"\"\n    try:\n        notebooks = notebook_manager.list_notebooks()\n        return {\"notebooks\": notebooks, \"total\": len(notebooks)}\n    except NotebookCorruptedError as exc:\n        raise _unreadable(exc)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.get(\"/statistics\")\nasync def get_statistics():\n    \"\"\"\n    Get notebook statistics\n\n    Returns:\n        Statistics information\n    \"\"\"\n    try:\n        stats = notebook_manager.get_statistics()\n        return stats\n    except NotebookCorruptedError as exc:\n        raise _unreadable(exc)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/notebook.py#L179-L215","documentation":"HTTP 500 raised by the notebook route handlers in deeptutor/api/routers/notebook.py:197 as a catch-all: after NotebookCorruptedError is mapped to a specific 4xx via _unreadable, any remaining unexpected exception (I/O failure, manager bug, unexpected data shape) is converted to detail=str(e). Trigger scenarios: unreadable storage backend during list_notebooks, corrupted metadata, or unforeseen runtime exceptions in any handler using this pattern.","triggerScenarios":"Thrown at deeptutor/api/routers/notebook.py:197 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap the list_notebooks call in try/except and log the underlying exception with the traceback before re-raising","Return a structured 500 payload (e.g. {detail: 'notebook listing failed'}) instead of leaking str(e) to clients","Distinguish expected notebook-store failures from programming errors and map them to appropriate status codes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","contentChangedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}