Class NoHostAvailableException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.datastax.driver.core.exceptions.DriverException
-
- com.datastax.driver.core.exceptions.NoHostAvailableException
-
- All Implemented Interfaces:
Serializable
public class NoHostAvailableException extends DriverException
Exception thrown when a query cannot be performed because no host is available.This exception is thrown if either:
- there is no host live in the cluster at the moment of the query;
- all hosts that have been tried have failed.
For debugging purposes, the list of hosts that have been tried along with the failure cause can be retrieved using the
getErrors()method.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description NoHostAvailableException(Map<EndPoint,Throwable> errors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NoHostAvailableExceptioncopy()Copy the exception.StringgetCustomMessage(int maxErrors, boolean formatted, boolean includeStackTraces)Builds a custom message for this exception.Map<EndPoint,Throwable>getErrors()Return the hosts tried along with the error encountered while trying them.-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
-
-
-
Method Detail
-
getErrors
public Map<EndPoint,Throwable> getErrors()
Return the hosts tried along with the error encountered while trying them.- Returns:
- a map containing for each tried host the error triggered when trying it.
-
getCustomMessage
public String getCustomMessage(int maxErrors, boolean formatted, boolean includeStackTraces)
Builds a custom message for this exception.- Parameters:
maxErrors- the maximum number of errors displayed (useful to limit the size of the message for big clusters). Beyond this limit, host names are still displayed, but not the associated errors. Set toInteger.MAX_VALUEto display all hosts.formatted- whether to format the output (line break between each host).includeStackTraces- whether to include the full stacktrace of each host error. Note that this automatically impliesformatted.- Returns:
- the message.
-
copy
public NoHostAvailableException copy()
Description copied from class:DriverExceptionCopy the exception.This returns a new exception, equivalent to the original one, except that because a new object is created in the current thread, the top-most element in the stacktrace of the exception will refer to the current thread (this is mainly intended for internal use by the driver). The cause of the copied exception will be the original exception.
- Overrides:
copyin classDriverException- Returns:
- a copy/clone of this exception.
-
-