Skip to content

Add exception handling for setting OpenAI API key#33

Merged
heyodai merged 1 commit intomainfrom
27-add-a-successfail-message-when-key-is-set
Nov 8, 2023
Merged

Add exception handling for setting OpenAI API key#33
heyodai merged 1 commit intomainfrom
27-add-a-successfail-message-when-key-is-set

Conversation

@heyodai
Copy link
Copy Markdown
Owner

@heyodai heyodai commented Nov 8, 2023

Modified the main function in magic_commit/__main__.py to include exception handling when setting the OpenAI API key. If setting the key raises an OSError, a message is printed indicating that the key could not be set. Any other exception is caught and printed for debugging purposes. Additionally, a success message is printed if the key is set successfully.

This change improves the robustness of the code by gracefully handling potential errors during the API key setup process.

Modified the `main` function in `magic_commit/__main__.py` to include exception handling when setting the OpenAI API key. If setting the key raises an `OSError`, a message is printed indicating that the key could not be set. Any other exception is caught and printed for debugging purposes. Additionally, a success message is printed if the key is set successfully.

This change improves the robustness of the code by gracefully handling potential errors during the API key setup process.
@heyodai heyodai linked an issue Nov 8, 2023 that may be closed by this pull request
@heyodai heyodai merged commit fef61c8 into main Nov 8, 2023
@heyodai heyodai deleted the 27-add-a-successfail-message-when-key-is-set branch November 8, 2023 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a success/fail message when key is set

1 participant