"""Code written to test integration of Honeybadger with hug. You need to : pip install honeybadger pip install hug Have a trial/free account for Honeybadger Set the Honeybadger API key as an environment variable HONEYBADGER_API_KEY Also set export HONEYBADGER_FORCE_REPORT_DATA=True else Exception may not be reported to Honeybadger Read their documentation to know why """ import hug import os from honeybadger import Honeybadger # Optional Honeybadger integration. It will kick in # only if HONEYBADGER_API_KEY environment variable is set API_KEY = os.environ.get('HONEYBADGER_API_KEY', None) if API_KEY: print("Setting up Honeybadger") hb = Honeybadger() hb.configure(api_key=API_KEY) @hug.exception(Exception) def handle_exception(exception): hb.notify(exception) raise exception else: print("Honeybadger not set, because not API_KEY was set.") @hug.get('/happy_birthday') def happy_birthday(name, age: hug.types.number = 1): """Says happy birthday to a user""" return "Happy {age} Birthday {name}!".format(**locals()) @hug.get('/exception') def raise_exception(): raise Exception("This will be reported")