Class KubernetesException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    ClientErrorException, WatchException

    public class KubernetesException
    extends java.io.IOException
    Signals that an exception of some sort has occurred while performing some cluster action. This class is the general class of exceptions produced by failed or interrupted k8s cluster operations.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      KubernetesException​(java.lang.String message, okhttp3.Response rawResponse)
      Constructs a KubernetesException with the specified detail message and OkHttp Response.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static KubernetesException forResponse​(java.lang.String message, okhttp3.Response rawResponse)
      Factory method to create KubernetesException based on the Response produced by the server.
      int getCode()
      Returns the HTTP status code that caused this exception.
      • 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

      • KubernetesException

        public KubernetesException​(java.lang.String message,
                                   okhttp3.Response rawResponse)
        Constructs a KubernetesException with the specified detail message and OkHttp Response.
        Parameters:
        message - The detail message.
        rawResponse - The OkHttp that caused this exception.
    • Method Detail

      • getCode

        public int getCode()
        Returns the HTTP status code that caused this exception.
        Returns:
        the HTTP status code.
      • forResponse

        public static KubernetesException forResponse​(java.lang.String message,
                                                      okhttp3.Response rawResponse)
        Factory method to create KubernetesException based on the Response produced by the server.

        Depending on the response code it will return a specific KubernetesException implementation applicable for that code. In case no specific KubernetesException is found a generic one will be returned.

        Parameters:
        message - The detail message for the KubernetesException.
        rawResponse - The Response from which to compute the applicable KubernetesException.
        Returns:
        the applicable KubernetesException instance.