B Y @s\dZddlmZddlZddlmZddlmZddlm Z ddl m Z Gdd d e Z dS) z raven.contrib.bottle ~~~~~~~~~~~~~~~~~~~ :copyright: (c) 2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. )absolute_importN)request) setup_logging)get_data_from_request) SentryHandlerc@s:eZdZdZdddZddZddZd d Zd d Zd S)Sentryav Bottle application for Sentry. >>> sentry = Sentry(app, client) Automatically configure logging:: >>> sentry = Sentry(app, client, logging=True) Capture an exception:: >>> try: >>> 1 / 0 >>> except ZeroDivisionError: >>> sentry.captureException() Capture a message:: >>> sentry.captureMessage('hello, world!') FcCs2||_||_||_|jr&tt|j||j_dS)N)appclientloggingrrZsentry)selfrr r r N/opt/alt/python37/lib/python3.7/site-packages/raven/contrib/bottle/__init__.py__init__)s zSentry.__init__cOs&|jj|dttd|jiddS)Nexc_infor)rdataextra)r captureExceptiongetrrr)r argskwargsr r r handle_exception1szSentry.handle_exceptioncsHdfdd }y ||Stk rBjtdYnXdS)Ncs |dk rj|d|||S)N)r)r)statusheadersr)r start_responser r session_start_response;s z/Sentry.__call__..session_start_response)r)N)r Exceptionrsysr)r environrrr )r rr __call__:s  zSentry.__call__cOsT|jstd|d}|dkrFytt|d<Wntk rDYnX|jj||S)Nz5captureException called before application configuredr)r AssertionErrorrrr RuntimeErrorr)r rrrr r r rHs zSentry.captureExceptioncOsT|jstd|d}|dkrFytt|d<Wntk rDYnX|jj||S)Nz3captureMessage called before application configuredr)r rrrrr captureMessage)r rrrr r r r!Ss zSentry.captureMessageN)F) __name__ __module__ __qualname____doc__rrrrr!r r r r rs    r)r% __future__rrbottlerZ raven.confrZraven.contrib.bottle.utilsrZraven.handlers.loggingrobjectrr r r r s