Record Class FailedHttpResponse<T>

java.lang.Object
java.lang.Record
meteordevelopment.meteorclient.utils.network.FailedHttpResponse<T>
All Implemented Interfaces:
HttpResponse<T>

public record FailedHttpResponse<T>(HttpRequest request, Exception exception) extends Record implements HttpResponse<T>
Failed HttpResponse object that is returned from Http sendRequest methods when HttpClient.send(HttpRequest, BodyHandler) throws an exception instead of returning an error response, such as when the connection is interrupted or an I/O error occurs. This object is used to prevent sendRequest methods from returning null.
  • Constructor Details

    • FailedHttpResponse

      public FailedHttpResponse(HttpRequest request, Exception exception)
      Creates an instance of a FailedHttpResponse record class.
      Parameters:
      request - the value for the request record component
      exception - the value for the exception record component
  • Method Details

    • statusCode

      public int statusCode()
      Specified by:
      statusCode in interface HttpResponse<T>
    • previousResponse

      public Optional<HttpResponse<T>> previousResponse()
      Specified by:
      previousResponse in interface HttpResponse<T>
    • headers

      public HttpHeaders headers()
      Specified by:
      headers in interface HttpResponse<T>
    • body

      public T body()
      Specified by:
      body in interface HttpResponse<T>
    • sslSession

      public Optional<SSLSession> sslSession()
      Specified by:
      sslSession in interface HttpResponse<T>
    • uri

      public URI uri()
      Specified by:
      uri in interface HttpResponse<T>
    • version

      @Nullable public HttpClient.Version version()
      Specified by:
      version in interface HttpResponse<T>
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • request

      public HttpRequest request()
      Returns the value of the request record component.
      Specified by:
      request in interface HttpResponse<T>
      Returns:
      the value of the request record component
    • exception

      public Exception exception()
      Returns the value of the exception record component.
      Returns:
      the value of the exception record component