def report_exception(self, msg, notify_user=True, level="<STR_LIT:error>", error_frame=None):
<EOL>py3_paths = [os.path.dirname(__file__)] + self.config["<STR_LIT>"]<EOL>traceback = None<EOL>try:<EOL><INDENT>exc_type, exc_obj, tb = sys.exc_info()<EOL>stack = extract_tb(tb)<EOL>error_str = "<STR_LIT>".format(exc_type.__name__, exc_obj)<EOL>traceback = [error_str]<EOL>if error_frame:<EOL><INDENT>traceback += format_stack(error_frame, <NUM_LIT:1>) + format_tb(tb)<EOL>filename = os.path.basename(error_frame.f_code.co_filename)<EOL>line_no = error_frame.f_lineno<EOL><DEDENT>else:<EOL><INDENT>traceback += format_tb(tb)<EOL>found = False<EOL>for item in reversed(stack):<EOL><INDENT>filename = item[<NUM_LIT:0>]<EOL>for path in py3_paths:<EOL><INDENT>if filename.startswith(path):<EOL><INDENT>filename = os.path.basename(item[<NUM_LIT:0>])<EOL>line_no = item[<NUM_LIT:1>]<EOL>found = True<EOL>break<EOL><DEDENT><DEDENT>if found:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>msg = "<STR_LIT>".format(<EOL>msg, exc_type.__name__, filename, line_no<EOL>)<EOL><DEDENT>except:  <EOL><INDENT>msg = "<STR_LIT>".format(msg)<EOL><DEDENT>finally:<EOL><INDENT>del tb<EOL><DEDENT>self.py3_wrapper.log(msg, "<STR_LIT>")<EOL>if traceback:<EOL><INDENT>if "<STR_LIT>" not in self.config:<EOL><INDENT>print_stderr("<STR_LIT:\n>".join(traceback))<EOL><DEDENT>elif self.config.get("<STR_LIT>"):<EOL><INDENT>self.py3_wrapper.log("<STR_LIT>".join(["<STR_LIT>"] + traceback))<EOL><DEDENT><DEDENT>if notify_user:<EOL><INDENT>self.py3_wrapper.notify_user(msg, level=level)<EOL><DEDENT>
Report details of an exception to the user.
This should only be called within an except: block Details of the
exception are reported eg filename, line number and exception type.

Because stack trace information outside of py3status or it's modules is
not helpful in actually finding and fixing the error, we try to locate
the first place that the exception affected our code.

Alternatively if the error occurs in a module via a Py3 call that
catches and reports the error then we receive an error_frame and use
that as the source of the error.

NOTE: msg should not end in a '.' for consistency.