|
|
@@ -38,28 +38,6 @@ def response_type(content_type): |
|
|
|
return func(*args, **kwargs) |
|
|
|
return decorator.decorator(wrapper) |
|
|
|
|
|
|
|
@decorator.decorator |
|
|
|
def workaround_cp_bug_1200(func, *args, **kwargs): # pragma: no cover |
|
|
|
"""Decorator to work around CherryPy bug #1200 in a response |
|
|
|
generator. |
|
|
|
|
|
|
|
Even if chunked responses are disabled, LookupError or |
|
|
|
UnicodeError exceptions may still be swallowed by CherryPy due to |
|
|
|
bug #1200. This throws them as generic Exceptions instead so that |
|
|
|
they make it through. |
|
|
|
""" |
|
|
|
exc_info = None |
|
|
|
try: |
|
|
|
for val in func(*args, **kwargs): |
|
|
|
yield val |
|
|
|
except (LookupError, UnicodeError): |
|
|
|
# Re-raise it, but maintain the original traceback |
|
|
|
exc_info = sys.exc_info() |
|
|
|
new_exc = Exception(exc_info[0].__name__ + ": " + str(exc_info[1])) |
|
|
|
raise new_exc.with_traceback(exc_info[2]) |
|
|
|
finally: |
|
|
|
del exc_info |
|
|
|
|
|
|
|
def exception_to_httperror(*expected): |
|
|
|
"""Return a decorator-generating function that catches expected |
|
|
|
errors and throws a HTTPError describing it instead. |
|
|
|