code: def capture_java_exception(f):
      def deco(*a, **kw):
          try:
              return f(*a, **kw)
          except Py4JJavaError as e:
              from pyflink.java_gateway import get_gateway
  
              get_gateway().jvm.org.apache.flink.client.python.PythonEnvUtils.setPythonException(
                  e.java_exception
              )
              s = e.java_exception.toString()
              for exception in exception_mapping.keys():
                  if s.startswith(exception):
                      java_exception = convert_py4j_exception(e)
                      break
              else:
                  raise
          raise java_exception
  
      return deco
  
imports: import py4j
  from py4j.protocol import Py4JJavaError
label_desc: Use image node_id 1 for calling a global function with example usage: capture_java_exception(f) and returns: deco, f