code: def format_error(error):
      
      formatted = {"message": str(error)}
  
      if hasattr(error, "traceback"):
          fname, line_no, func, exc = error.traceback
          formatted.update({
              "fname": fname,
              "line_number": line_no,
              "func": func,
              "exc": exc
          })
  
      return formatted
docs: Serialise exception