code: def json_traceback(error_msg=None):
      
  
      exception_data = traceback.format_exc().splitlines()
      if error_msg is None:
          error_msg = '\n'.join(exception_data)
      else:
          error_msg = 'Remote RPC error: {}'.format(error_msg)
  
      return {
          'error': error_msg,
          'traceback': exception_data
      }
docs: Generate a stack trace as a JSON-formatted error message.
      Optionally use error_msg as the error field.
      Return {'error': ..., 'traceback'...}