From 419952f33b886d72c376c3bb02be8dc214442cc1 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Thu, 6 Feb 2025 09:51:33 -0800 Subject: [PATCH] refactor: Convert exception_names to dict mapping names to ExInfo --- aider/exceptions.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/aider/exceptions.py b/aider/exceptions.py index 02617eb3b..04f91dd46 100644 --- a/aider/exceptions.py +++ b/aider/exceptions.py @@ -52,7 +52,7 @@ EXCEPTIONS = [ class LiteLLMExceptions: exceptions = dict() - exception_names = {exi.name for exi in EXCEPTIONS} + exception_info = {exi.name: exi for exi in EXCEPTIONS} def __init__(self): self._load() @@ -61,12 +61,13 @@ class LiteLLMExceptions: import litellm for var in dir(litellm): - if var.endswith("Error") and var not in self.exception_names: - raise ValueError(f"{var} is in litellm but not in aider's exceptions list") - - ex = getattr(litellm, var) - dump(var, ex) - self.exceptions[ex] = ex_info + if var.endswith("Error"): + if var not in self.exception_info: + raise ValueError(f"{var} is in litellm but not in aider's exceptions list") + + ex = getattr(litellm, var) + dump(var, ex) + self.exceptions[ex] = self.exception_info[var] def exceptions_tuple(self): return tuple(self.exceptions)