def handle_exception(self, exc_info=None, state=None, tags=None, return_feedback_urls=False,<EOL>dry_run=False):
if not exc_info:<EOL><INDENT>exc_info = sys.exc_info()<EOL><DEDENT>if exc_info is None:<EOL><INDENT>raise StackSentinelError("<STR_LIT>")<EOL><DEDENT>(etype, value, tb) = exc_info<EOL>try:<EOL><INDENT>msg = value.args[<NUM_LIT:0>]<EOL><DEDENT>except:<EOL><INDENT>msg = repr(value)<EOL><DEDENT>if not isinstance(tags, list):<EOL><INDENT>tags = [tags]<EOL><DEDENT>limit = None<EOL>new_tb = []<EOL>n = <NUM_LIT:0><EOL>while tb is not None and (limit is None or n < limit):<EOL><INDENT>f = tb.tb_frame<EOL>lineno = tb.tb_lineno<EOL>co = f.f_code<EOL>filename = co.co_filename<EOL>name = co.co_name<EOL>tb = tb.tb_next<EOL>n = n + <NUM_LIT:1><EOL>new_tb.append({'<STR_LIT>': lineno, '<STR_LIT>': filename, '<STR_LIT>': name})<EOL><DEDENT>if state is None:<EOL><INDENT>state = {}<EOL><DEDENT>if '<STR_LIT>' not in state:<EOL><INDENT>try:<EOL><INDENT>state['<STR_LIT>'] = self._get_sys_info()<EOL><DEDENT>except Exception as e:<EOL><INDENT>state['<STR_LIT>'] = '<STR_LIT>' % e<EOL><DEDENT><DEDENT>if '<STR_LIT>' not in state:<EOL><INDENT>try:<EOL><INDENT>state['<STR_LIT>'] = self._get_machine_info()<EOL><DEDENT>except Exception as e:<EOL><INDENT>state['<STR_LIT>'] = '<STR_LIT>' % e<EOL><DEDENT><DEDENT>if tags is None:<EOL><INDENT>tags = []<EOL><DEDENT>if sys.version_info.major > <NUM_LIT:2>:<EOL><INDENT>error_type = str(etype.__name__)<EOL>error_message = str(value)<EOL><DEDENT>else:<EOL><INDENT>error_type = unicode(etype.__name__)<EOL>error_message = unicode(value)<EOL><DEDENT>send_error_args = dict(error_type=error_type,<EOL>error_message=error_message,<EOL>traceback=new_tb,<EOL>environment=self.environment,<EOL>state=state,<EOL>tags=self.tags + tags,<EOL>return_feedback_urls=return_feedback_urls)<EOL>if dry_run:<EOL><INDENT>return send_error_args<EOL><DEDENT>else:<EOL><INDENT>return self.send_error(**send_error_args)<EOL><DEDENT>
Call this method from within a try/except clause to generate a call to Stack Sentinel.

:param exc_info: Return value of sys.exc_info(). If you pass None, handle_exception will call sys.exc_info() itself
:param state: Dictionary of state information associated with the error. This could be form data, cookie data, whatnot. NOTE: sys and machine are added to this dictionary if they are not already included.
:param tags: Any string tags you want associated with the exception report.
:param return_feedback_urls: If True, Stack Sentinel will return feedback URLs you can present to the user for extra debugging information.
:param dry_run: If True, method will not actively send in error information to API. Instead, it will return a request object and payload. Used in unittests.