Class ProtocolException

  • All Implemented Interfaces:
    java.io.Serializable

    public class ProtocolException
    extends FaunaException
    Exception representing protocol-level errors in communication with Fauna.

    This exception is typically thrown when there is an unexpected shape is received on response.. Extends FaunaException to provide details specific to protocol errors.

    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ProtocolException​(int statusCode, QueryFailure failure)
      Constructs a ProtocolException with the specified HTTP status code and QueryFailure details.
      ProtocolException​(int statusCode, java.lang.String body)
      Constructs a ProtocolException with the specified HTTP status code and response body.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getBody()
      Retrieves the response body associated with this protocol error, if available.
      java.util.Optional<QueryFailure> getQueryFailure()
      Retrieves the QueryFailure details associated with this protocol error, if available.
      int getStatusCode()
      Retrieves the HTTP status code associated with this protocol error.
      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ProtocolException

        public ProtocolException​(int statusCode,
                                 QueryFailure failure)
        Constructs a ProtocolException with the specified HTTP status code and QueryFailure details.
        Parameters:
        statusCode - The HTTP status code received.
        failure - The QueryFailure object containing details about the protocol failure.
      • ProtocolException

        public ProtocolException​(int statusCode,
                                 java.lang.String body)
        Constructs a ProtocolException with the specified HTTP status code and response body.
        Parameters:
        statusCode - The HTTP status code received.
        body - A String containing the response body associated with the failure.
    • Method Detail

      • getStatusCode

        public int getStatusCode()
        Retrieves the HTTP status code associated with this protocol error.
        Returns:
        An int representing the HTTP status code.
      • getBody

        public java.lang.String getBody()
        Retrieves the response body associated with this protocol error, if available.
        Returns:
        A String containing the response body, or null if the body is unavailable.
      • getQueryFailure

        public java.util.Optional<QueryFailure> getQueryFailure()
        Retrieves the QueryFailure details associated with this protocol error, if available.
        Returns:
        An Optional<QueryFailure> containing the failure details, or Optional.empty() if not present.