Enhanced exception handling for Python with visual tracebacks, solution suggestions, and cloud logging
Project description
🔍 ErrorTrace Pro
Enhanced exception handling for Python with visual tracebacks, solution suggestions, and cloud logging.
Ever stared at a Python exception and wondered what went wrong? ErrorTrace Pro transforms cryptic tracebacks into clear, actionable insights. With stunning visualizations, solution suggestions, and integrated cloud logging, it's the exception handler you've always wanted.
Features
- Visual Traceback Mapping: Beautiful, colorful, and informative tracebacks that highlight exactly what went wrong
- Common Solution Database: Intelligent suggestions to fix exceptions based on a comprehensive solutions library
- Multi-Cloud Logging: Seamlessly log exceptions to GCP, AWS, Azure, or custom HTTP endpoints
- Drop-in Integration: Works with any Python codebase with minimal configuration
- Powerful CLI: Run scripts with enhanced error handling directly from the command line
Installation
pip install errortrace-pro
Optional Features
ErrorTrace Pro provides several installation options for enhanced functionality:
# Install with Rich for enhanced visual output
pip install errortrace-pro[rich]
# Install with Click for better CLI experience
pip install errortrace-pro[cli]
# Install all optional dependencies
pip install errortrace-pro[all]
Quick Start
Basic Usage
The simplest way to use ErrorTrace Pro is to install it as a global exception handler:
import errortrace_pro
# Install as global exception handler
errortrace_pro.install()
# Now all unhandled exceptions will be processed by ErrorTrace Pro
def main():
# Your code here
result = 10 / 0 # This will trigger a ZeroDivisionError with enhanced output
if __name__ == "__main__":
main()
With Custom Settings
You can customize the behavior of ErrorTrace Pro:
import errortrace_pro
# Initialize with custom settings
handler = errortrace_pro.init(
solutions_path="custom_solutions.json", # Path to your custom solutions database
cloud_logging=True, # Enable cloud logging
cloud_provider="gcp", # Use Google Cloud for logging
api_key="your-api-key", # API key for cloud logging
project_id="your-project-id", # Project ID for cloud logging
enable_suggestions=True, # Enable solution suggestions
colored_output=True, # Enable colored output
verbose=True # Enable verbose output
)
# Install the custom handler
errortrace_pro.install(handler)
# Your code here
Advanced Usage
Running the CLI Tool
ErrorTrace Pro provides a command-line tool to run scripts with enhanced error handling:
# Run a script with ErrorTrace Pro
errortrace run script.py
# Run with cloud logging enabled
errortrace run script.py --cloud --provider=http --endpoint=http://logs.example.com
# Run with custom solutions database
errortrace run script.py --solutions=custom_solutions.json
# Generate a template solutions database
errortrace init-solutions --output=custom_solutions.json
Creating a Custom Solutions Database
You can create a custom solutions database to provide specific suggestions for your own exceptions:
{
"CustomError": [
"This is a custom solution for CustomError",
"Another solution for this error type"
],
"ValueError": [
"Additional custom solution for ValueError",
"Try converting the value to the correct type first"
]
}
Setting Up Cloud Logging
ErrorTrace Pro supports logging exceptions to various cloud providers:
- Generic HTTP endpoint
- Google Cloud Logging
- AWS CloudWatch
- Azure Application Insights
Configure cloud logging with environment variables:
# Set environment variables for cloud logging
export ERRORTRACE_PROVIDER="gcp"
export ERRORTRACE_API_KEY="your-api-key"
export ERRORTRACE_PROJECT_ID="your-project-id"
export ERRORTRACE_ENDPOINT="http://logs.example.com"
Or set up programmatically:
import os
os.environ["ERRORTRACE_PROVIDER"] = "gcp"
os.environ["ERRORTRACE_API_KEY"] = "your-api-key"
os.environ["ERRORTRACE_PROJECT_ID"] = "your-project-id"
Testing Cloud Logging
Using a Generic HTTP Endpoint
The easiest way to test cloud logging without setting up actual cloud accounts:
import errortrace_pro
# Initialize with HTTP endpoint logging
handler = errortrace_pro.init(
cloud_logging=True,
cloud_provider="http",
api_key="test-key", # Can be any value for testing
endpoint="https://httpbin.org/post" # This is a test endpoint that echoes back what you send
)
# Install the handler
errortrace_pro.install(handler)
# Generate an exception to test
def cause_error():
# This will cause a ZeroDivisionError
return 1/0
try:
cause_error()
except Exception:
pass # The handler will log the exception
Testing with Google Cloud (GCP)
import os
# Set environment variables
os.environ["ERRORTRACE_PROVIDER"] = "gcp"
os.environ["ERRORTRACE_API_KEY"] = "your-gcp-api-key"
os.environ["ERRORTRACE_PROJECT_ID"] = "your-gcp-project-id"
# Initialize ErrorTrace Pro
import errortrace_pro
handler = errortrace_pro.init(cloud_logging=True)
errortrace_pro.install(handler)
# Cause an error
1/0 # This will be logged to GCP
Testing with AWS CloudWatch
import os
# Set environment variables
os.environ["ERRORTRACE_PROVIDER"] = "aws"
os.environ["ERRORTRACE_API_KEY"] = "your-aws-access-key-id"
os.environ["ERRORTRACE_SECRET_KEY"] = "your-aws-secret-access-key"
os.environ["ERRORTRACE_REGION"] = "us-east-1" # Or your preferred region
# Initialize ErrorTrace Pro
import errortrace_pro
handler = errortrace_pro.init(cloud_logging=True)
errortrace_pro.install(handler)
# Cause an error
1/0 # This will be logged to AWS CloudWatch
Testing with Azure Application Insights
import os
# Set environment variables
os.environ["ERRORTRACE_PROVIDER"] = "azure"
os.environ["ERRORTRACE_API_KEY"] = "your-azure-instrumentation-key"
# Initialize ErrorTrace Pro
import errortrace_pro
handler = errortrace_pro.init(cloud_logging=True)
errortrace_pro.install(handler)
# Cause an error
1/0 # This will be logged to Azure Application Insights
API Reference
Core Functions
| Function | Description |
|---|---|
errortrace_pro.init() |
Initialize ErrorTrace Pro with custom settings |
errortrace_pro.install() |
Install ErrorTrace Pro as the global exception handler |
errortrace_pro.uninstall() |
Restore the original sys.excepthook |
Classes
| Class | Description |
|---|---|
errortrace_pro.handler.ExceptionHandler |
The main exception handler class |
errortrace_pro.visualizer.TracebackVisualizer |
The traceback visualization class |
errortrace_pro.solutions.SolutionProvider |
The solution provider class |
errortrace_pro.cloud_logger.CloudLogger |
The cloud logging class |
Contributing
Please read our CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
Roadmap
- AI-powered solution suggestions
- Integration with more IDEs and tools
- Performance profiling during exception handling
- Customizable visualization themes
- Multi-language support
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- The Rich library for beautiful terminal formatting
- The open-source Python community for inspiration and support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file errortrace_pro-0.3.0.tar.gz.
File metadata
- Download URL: errortrace_pro-0.3.0.tar.gz
- Upload date:
- Size: 26.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce4270157fd46382d250005a48a3bdbd4fd02ff94c10c93d7f2d741087af6b5c
|
|
| MD5 |
297ecf1f5c97a328200463f12d731d35
|
|
| BLAKE2b-256 |
044c4c6897e9fa26f3434579ae8f27ffc9fe4969792e2035c4b9c1b3ee31c01f
|
File details
Details for the file errortrace_pro-0.3.0-py3-none-any.whl.
File metadata
- Download URL: errortrace_pro-0.3.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89ad4997377fdd2e26cb5a500f17698d109ac5e97ed21d40dbaee18c5a7c4d4b
|
|
| MD5 |
863d59ddaf7694f7cd8928e471bfe5b5
|
|
| BLAKE2b-256 |
2e639c403ae1bf71743632de757e1fb4d38bfb5efbe12bc1dd3505893129afbb
|