mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-12-07 01:58:17 +01:00
Rewrite FlareSolverr from scratch in Python + Selenium
This commit is contained in:
22
src/bottle_plugins/error_plugin.py
Normal file
22
src/bottle_plugins/error_plugin.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user