Spaces:
Runtime error
Runtime error
Download src/bottle_plugins/error_plugin.py from sanjay7178/flaresolverr: direct link, hf CLI and curl.
- Browser
- Download file 523 Bytes
-
https://huggingface.co/spaces/sanjay7178/flaresolverr/resolve/main/src/bottle_plugins/error_plugin.py
- Command line
-
hf download hf://spaces/sanjay7178/flaresolverr/src/bottle_plugins/error_plugin.py
-
curl -L -o error_plugin.py https://huggingface.co/spaces/sanjay7178/flaresolverr/resolve/main/src/bottle_plugins/error_plugin.py
523 Bytes
| from bottle import response | |
| import logging | |
| def error_plugin(callback): | |
| """ | |
| Bottle plugin to handle exceptions | |
| https://stackoverflow.com/a/32764250 | |
| """ | |
| def wrapper(*args, **kwargs): | |
| try: | |
| actual_response = callback(*args, **kwargs) | |
| except Exception as e: | |
| logging.error(str(e)) | |
| actual_response = { | |
| "error": str(e) | |
| } | |
| response.status = 500 | |
| return actual_response | |
| return wrapper | |