Skip to content

Commit d8dbbd3

Browse files
committed
Wrap OpenAIError in a ConfigError when initializing from config so we don't show a full traceback.
Closes #1.
1 parent 148f7d8 commit d8dbbd3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/gptcmd/llm/openai.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ def from_config(cls, conf: Dict):
4343
)
4444
model = conf.get("model")
4545
client_opts = {k: v for k, v in conf.items() if k not in SPECIAL_OPTS}
46-
client = openai.OpenAI(**client_opts)
46+
try:
47+
client = openai.OpenAI(**client_opts)
48+
except openai.OpenAIError as e:
49+
# Import late to avoid circular import
50+
from ..config import ConfigError
51+
52+
raise ConfigError(str(e)) from e
4753
return cls(client, model=model)
4854

4955
def _message_to_openai(self, msg: Message) -> Dict[str, Any]:

0 commit comments

Comments
 (0)