code: def check_error(res, error_enum):
      """Raise if the result has an error, otherwise return the result."""
      if res.HasField("error"):
          enum_name = error_enum.DESCRIPTOR.full_name
          error_name = error_enum.Name(res.error)
          details = getattr(res, "error_details", "<none>")
          raise RequestError(
              "%s.%s: '%s'" % (enum_name, error_name, details), res
          )
      return res
  
imports: import copy
  import functools
  import socket
  import sys
  import time
  from absl import flags
  from absl import logging
  from pysc2.lib import protocol
  from pysc2.lib import static_data
  from pysc2.lib import stopwatch
  import websocket
  from s2clientprotocol import debug_pb2
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 1 for calling a global function with example usage: check_error(res, error_enum) and returns: res