semvec/pypi-packages huggingface dataset:
unhandled-exception-logger 0.0.3
Log unhandled exceptions as critical

# Log Unhandled Exceptions

This package will log unhandled exceptions as a critical error.

# Install

```
pip install unhandled-exception-logger
```

# Usage

For use in generic python code:

```
from unhandled_exception_logger import unhandled_exception_setup

unhandled_exception_setup()
```

## Flask usage

If using Flask, then you'll need to register the `handle_exception` function
using the `@app.errorhandler(Exception)` decorator, otherwise Flask 500
errors won't be sent.
```
from unhandled_exception_logger import unhandled_exception_setup, handle_exception
import logging

unhandled_exception_setup()

app = Flask(__name__)
logging.getLogger("werkzeug").disabled = True
app.logger.disabled = True
@app.errorhandler(Exception)
def flask_handle_exception(e):
    handle_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])

@app.route("/")
def home():
    return "home"

```

If you wish to, you can pass a custom handler to these critical unhandled
exceptions:


```
import sys
import logging
import os
from flask import Flask
from unhandled_exception_logger import (
    unhandled_exception_setup,
    handle_exception,
)

PYTHON_LOG_LEVEL = os.getenv("PYTHON_LOG_LEVEL", "DEBUG")


# Register myChstomHandler log handler
myChstomHandler = MyCustomHandler()
myChstomHandler.setLevel("CRITICAL")

unhandled_exception_setup(handler=myChstomHandler)


logger = logging.getLogger()
logger.setLevel(PYTHON_LOG_LEVEL)
logger.addHandler(myChstomHandler)


# # Direct all uncaught exceptions to handle_exception
sys.excepthook = handle_exception

# Minimal python app example with example unhandled exception
app = Flask(__name__)


@app.errorhandler(Exception)
def flask_handle_exception(e):
    handle_exception(
        sys.exc_info()[0],
        sys.exc_info()[1],
        sys.exc_info()[2],
        handler=MyCustomHandler,  # noqa: E501
    )


@app.errorhandler(500)
def error_page(e):
    return "An error occurred"

@app.route("/")
def home():
    return "home"

@app.route("/error")
def error():
    names = ["Bob", "Alice"]
    print(names[2])
    return "<p>Hello, World!</p>"
```


Inspired by

- [Insult error](https://github.com/keithfma/insult_error)
transports 0.1.2
Generic communication library
Requires Python: >=3.7

# transports
Generic communication library

[![Build Status](https://github.com/timkpaine/transports/workflows/Build%20Status/badge.svg?branch=main)](https://github.com/timkpaine/transports/actions?query=workflow%3A%22Build+Status%22)
[![codecov](https://codecov.io/gh/timkpaine/transports/branch/main/graph/badge.svg)](https://codecov.io/gh/timkpaine/transports)
[![License](https://img.shields.io/github/license/timkpaine/transports)](https://github.com/timkpaine/transports)
[![PyPI](https://img.shields.io/pypi/v/transports.svg)](https://pypi.python.org/pypi/transports)
<!-- [![npm](https://img.shields.io/npm/v/transports.svg)](https://www.npmjs.com/package/transports) -->