class_docstr: A handle to a query that is executing continuously in the background as new data arrives.
  All these methods are thread-safe.
  
  .. versionadded:: 2.0.0
  
  .. versionchanged:: 3.5.0
      Supports Spark Connect.
  
  Notes
  -----
  This API is evolving.
docstr: .. versionadded:: 2.1.0
  
  .. versionchanged:: 3.5.0
      Supports Spark Connect.
  
  Returns
  -------
  :class:`StreamingQueryException`
      the StreamingQueryException if the query was terminated by an exception, or None.
docstr_tok: ["..","versionadded",":",":","2.1.0","..","versionchanged",":",":","3.5.0","Supports","Spark","Connect",".","Returns","--","--","--","-",":","class",":","`","StreamingQueryException","`","the","StreamingQueryException","if","the","query","was","terminated","by","an","exception",",","or","None","."]
code: def exception(self) -> Optional[StreamingQueryException]:
      """
      .. versionadded:: 2.1.0
  
      .. versionchanged:: 3.5.0
          Supports Spark Connect.
  
      Returns
      -------
      :class:`StreamingQueryException`
          the StreamingQueryException if the query was terminated by an exception, or None.
      """
      if self._jsq.exception().isDefined():
          je = self._jsq.exception().get()
          msg = je.toString().split(": ", 1)[
              1
          ]  # Drop the Java StreamingQueryException type info
          stackTrace = "\n\t at ".join(
              map(lambda x: x.toString(), je.getStackTrace())
          )
          return CapturedStreamingQueryException(
              msg, stackTrace, je.getCause()
          )
      else:
          return None
  
imports: import json
  from typing import Any, Dict, List, Optional
  from py4j.java_gateway import JavaObject, java_import
  from pyspark.errors import StreamingQueryException, PySparkValueError
  from pyspark.errors.exceptions.captured import StreamingQueryException
  from pyspark.sql.streaming.listener import StreamingQueryListener
label_desc: Use image node_id 13 for calling the StreamingQuery obj's underlying member method code with example usage: obj.exception() and returns: CapturedStreamingQueryException, None