com.marklogic.xcc.exceptions

## Class QueryException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - com.marklogic.xcc.exceptions.XccException
      - - com.marklogic.xcc.exceptions.RequestException
        - - com.marklogic.xcc.exceptions.RequestServerException
          - - com.marklogic.xcc.exceptions.QueryException

- All Implemented Interfaces:
    java.io.Serializable
  Direct Known Subclasses:
    JavaScriptException, RetryableQueryException, XQueryException

      public abstract class QueryException
      extends RequestServerException

  A server exception resulting from an error encountered while evaluating a query. Note that some such exceptions are retryable.
  See Also:
    `RequestException.isRetryable()`, `RetryableQueryException`, Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryException(Request request, java.lang.String code, java.lang.String w3cCode, java.lang.String message, java.lang.String formatString, java.lang.String expr, boolean isRetryable, java.lang.String[] data, QueryStackFrame[] stack)` Constructs an XQueryException

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getCode()` Returns the server error code for this XQuery exception.
    `java.lang.String[]` | `getData()`
    `java.lang.String` | `getFormatString()`
    `QueryStackFrame[]` | `getStack()` Get an array of `QueryStackFrame` objects that represent the query stack frame returned by the server.
    `java.lang.String` | `getW3CCode()` Returns the error code defined by the WC3 XQuery spec that corresponds to this exception, if any.
    `java.lang.String` | `toString()` Returns a string representation (possibly multiple lines) of the error message and stack frame.

    - ### Methods inherited from class com.marklogic.xcc.exceptions.RequestException

      `appendRequestInfo, getRequest, isRetryable, isRetryAdvised`

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### QueryException

          public QueryException(Request request,
                                java.lang.String code,
                                java.lang.String w3cCode,
                                java.lang.String message,
                                java.lang.String formatString,
                                java.lang.String expr,
                                boolean isRetryable,
                                java.lang.String[] data,
                                QueryStackFrame[] stack)

      Constructs an XQueryException
      Parameters:
        `request` - The `Request` object to which this exception applies
        `code` - the symbolic exception code
        `w3cCode` - the exception code defined by the XQuery spec, if any
        `message` - the exception message
        `formatString` - the exception format string
        `expr` - The expression that caused the exception, if applicable
        `isRetryable` - retrying the operation may succeed
        `data` - the exception data
        `stack` - the xquery evaluator stack trace

  - ### Method Detail

    - #### getCode

          public java.lang.String getCode()

      Returns the server error code for this XQuery exception.
      Returns:
        A string that is a server error code, such as XDMP-FOO.

    - #### getW3CCode

          public java.lang.String getW3CCode()

      Returns the error code defined by the WC3 XQuery spec that corresponds to this exception, if any.
      Returns:
        A string that is the W3C error code, such as err:BLAH123, if one is defined, else null.
      Since:
        4.0

    - #### getFormatString

          public java.lang.String getFormatString()

    - #### getData

          public java.lang.String[] getData()

    - #### getStack

          public QueryStackFrame[] getStack()

      Get an array of `QueryStackFrame` objects that represent the query stack frame returned by the server.
      Returns:
        An array (possibly zero length) of XQuery evaluator stack frames.

    - #### toString

          public java.lang.String toString()

      Returns a string representation (possibly multiple lines) of the error message and stack frame.
      Overrides:
        `toString` in class `RequestException`
      Returns:
        A string representation of this Query exception.

Copyright © 2025 MarkLogic Corporation. All Rights Reserved.

Complete online documentation for MarkLogic Server, XQuery and related components may be found at developer.marklogic.com