refactor(ai_client): narrow 'except:' to specific types in _classify_deepseek/minimax_error (Phase 9 sites 1+2)
The bare 'except:' in _classify_deepseek_error (L332) and _classify_minimax_error (L355) was classified as INTERNAL_BROAD_CATCH. Narrowed to 'except (ValueError, AttributeError)' since the only realistic exceptions from exc.response.json() are JSONDecodeError (subclass of ValueError) and AttributeError (if exc.response is None or .json() is missing).
This commit is contained in:
+2
-2
@@ -329,7 +329,7 @@ def _classify_deepseek_error(exc: Exception, source: str = "ai_client.deepseek")
|
||||
err_data = exc.response.json()
|
||||
if "error" in err_data: body = str(err_data["error"].get("message", exc.response.text))
|
||||
else: body = exc.response.text
|
||||
except:
|
||||
except (ValueError, AttributeError):
|
||||
body = exc.response.text
|
||||
else:
|
||||
body = str(exc)
|
||||
@@ -352,7 +352,7 @@ def _classify_minimax_error(exc: Exception, source: str = "ai_client.minimax") -
|
||||
err_data = exc.response.json()
|
||||
if "error" in err_data: body = str(err_data["error"].get("message", exc.response.text))
|
||||
else: body = exc.response.text
|
||||
except:
|
||||
except (ValueError, AttributeError):
|
||||
body = exc.response.text
|
||||
else:
|
||||
body = str(exc)
|
||||
|
||||
Reference in New Issue
Block a user