Private
Public Access
0
0
Commit Graph

1 Commits

Author SHA1 Message Date
ed 37ece145fa refactor(ai_client): apply Re-Raise Pattern 1 to 4 RETHROW sites (Phase 12)
Per styleguide §7.6 Pattern 1: 'catch + convert + raise as different type'
requires 'raise X from e' to preserve the original exception in the
traceback.

Sites updated:

Site 1 (L277 _load_credentials):
  except FileNotFoundError as e:
      raise FileNotFoundError(f'...') from e

Sites 2+3 (L878+L879 _default_send, nested in run_with_tool_loop):
  if not res.ok:
      raise res.errors[0].original from None
      raise RuntimeError(...) from None
  The exceptions come from a Result, not a local except; 'from None'
  suppresses the implicit context.

Site 5 (L2061 _send inside _send_gemini_cli):
  raise cast(Exception, send_result.errors[0].original) from None

Site 6 (L2742 _dashscope_call):
  raise classify_dashscope_error(_dashscope_exception_from_response(resp)) from None

KNOWN LIMITATION: the audit script does not have a heuristic for
'raise X from e' / 'from None' (Pattern 1). The sites remain
INTERNAL_RETHROW in the audit. INTERNAL_RETHROW is 'suspicious but
not violation' (strict mode accepts). Adding a heuristic requires
Tier 1 approval per the conventions.

Audit: ai_client RETHROW 6 -> 5 (site 4 migrated separately; these
4 sites stay as INTERNAL_RETHROW by audit classification but follow
Pattern 1 by styleguide).
2026-06-20 15:48:00 -04:00