https://github.com/fkhan0520/cgpt_exceptions Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} fkhan0520 / cgpt_exceptions Public * Notifications * Fork 1 * Star 14 License GPL-3.0 license 14 stars 1 fork Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights fkhan0520/cgpt_exceptions This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/f] Use Git or checkout with SVN using the web URL. [gh repo clone fkhan0] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit Farhan Khan and Farhan Khan add readme/gitignore and handle invoking from python cli ... 080d2cf Dec 6, 2022 add readme/gitignore and handle invoking from python cli 080d2cf Git stats * 3 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time cgpt_exceptions add readme/gitignore and handle invoking from python cli Dec 6, 2022 .gitignore add readme/gitignore and handle invoking from python cli Dec 6, 2022 LICENSE Initial commit Dec 6, 2022 README.md add readme/gitignore and handle invoking from python cli Dec 6, 2022 setup.py real initial commit Dec 6, 2022 View code cgpt_exceptions Usage How it works README.md cgpt_exceptions Use ChatGPT to give helpful advice when your python program fails Usage 1. Install through git: pip install git+https://github.com/fkhan0520/cgpt_exceptions 2. Create a cgpt_exceptions_config.json file with your OpenAI auth info and put it in the same directory as wherever python is invoked. It can use either your username/password or auth token. Full details in the revChatGPT docs 3. Just import the package and invoke your program as normal! import cgpt_exceptions import os def foo(): os.listdir("a-random-directory") foo() Traceback (most recent call last) File "/Users/farhan/test.py", line 7, in foo() File "/Users/farhan/test.py", line 5, in foo os.listdir("a-random-directory") FileNotFoundError: [Errno 2] No such file or directory: 'a-random-directory' Let's see what ChatGPT has to say... Here are a few ways you can correct the exception: 1. Make sure that the directory "a-random-directory" exists and you have permission to access it. 2. Handle the `FileNotFoundError` exception that is raised when the directory doesn't exist by using a `try`-`except` block: import os def foo(): try: os.listdir("a-random-directory") except FileNotFoundError: print("Directory not found.") foo() How it works Sends ChatGPT the following prompt when an exception is thrown anywhere during execution: Please correct the following python exception: from the following code: Huge thanks to acheong8 for making this super straightforward with their revChatGPT package About No description, website, or topics provided. Resources Readme License GPL-3.0 license Stars 14 stars Watchers 1 watching Forks 1 fork Releases No releases published Packages 0 No packages published Languages * Python 100.0% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.