public class ElasticsearchException extends java.lang.RuntimeException implements ToXContent, Writeable
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Writeable.Reader<V>, Writeable.Writer<V>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
REST_EXCEPTION_SKIP_CAUSE |
static boolean |
REST_EXCEPTION_SKIP_CAUSE_DEFAULT |
static java.lang.String |
REST_EXCEPTION_SKIP_STACK_TRACE |
static boolean |
REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT |
EMPTY_PARAMS
Constructor and Description |
---|
ElasticsearchException(StreamInput in) |
ElasticsearchException(java.lang.String msg,
java.lang.Object... args)
Construct a
ElasticsearchException with the specified detail message. |
ElasticsearchException(java.lang.String msg,
java.lang.Throwable cause,
java.lang.Object... args)
Construct a
ElasticsearchException with the specified detail message
and nested exception. |
ElasticsearchException(java.lang.Throwable cause)
Construct a
ElasticsearchException with the specified cause exception. |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String key,
java.util.List<java.lang.String> value)
Adds a new header with the given key.
|
void |
addHeader(java.lang.String key,
java.lang.String... value)
Adds a new header with the given key.
|
protected void |
causeToXContent(XContentBuilder builder,
ToXContent.Params params)
Renders a cause exception as xcontent
|
java.lang.String |
getDetailedMessage()
Return the detail message, including the message from the nested exception
if there is one.
|
protected java.lang.String |
getExceptionName() |
static java.lang.String |
getExceptionName(java.lang.Throwable ex)
Returns a underscore case name for the given exception.
|
java.util.List<java.lang.String> |
getHeader(java.lang.String key)
Returns the list of header values for the given key or
null if not header for the
given key exists. |
java.util.Set<java.lang.String> |
getHeaderKeys()
Returns a set of all header keys on this exception
|
static int |
getId(java.lang.Class<? extends ElasticsearchException> exception)
Returns the serialization id the given exception.
|
Index |
getIndex() |
java.util.List<java.lang.String> |
getResourceId() |
java.lang.String |
getResourceType() |
java.lang.Throwable |
getRootCause()
Retrieve the innermost cause of this exception, if none, returns the current exception.
|
ShardId |
getShardId() |
ElasticsearchException[] |
guessRootCauses()
Returns the root cause of this exception or multiple if different shards caused different exceptions
|
static ElasticsearchException[] |
guessRootCauses(java.lang.Throwable t)
Returns the root cause of this exception or multiple if different shards caused different exceptions.
|
protected void |
innerToXContent(XContentBuilder builder,
ToXContent.Params params)
Renders additional per exception information into the xcontent
|
static boolean |
isRegistered(java.lang.Class<? extends java.lang.Throwable> exception)
Returns
true iff the given class is a registered for an exception to be read. |
static ElasticsearchException |
readException(StreamInput input,
int id) |
static <T extends java.lang.Throwable> |
readStackTrace(T throwable,
StreamInput in)
Deserializes stacktrace elements as well as suppressed exceptions from the given output stream and
adds it to the given exception.
|
static void |
renderException(XContentBuilder builder,
ToXContent.Params params,
java.lang.Exception e) |
protected void |
renderHeader(XContentBuilder builder,
ToXContent.Params params) |
void |
setIndex(Index index) |
void |
setIndex(java.lang.String index) |
void |
setResources(java.lang.String type,
java.lang.String... id) |
void |
setShard(ShardId shardId) |
void |
setShard(java.lang.String index,
int shardId) |
RestStatus |
status()
Returns the rest status code associated with this exception.
|
java.lang.String |
toString() |
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
static void |
toXContent(XContentBuilder builder,
ToXContent.Params params,
java.lang.Throwable ex)
Statis toXContent helper method that also renders non
ElasticsearchException instances as XContent. |
java.lang.Throwable |
unwrapCause()
Unwraps the actual cause from the exception for cases when the exception is a
ElasticsearchWrapperException . |
static <T extends java.lang.Throwable> |
writeStackTraces(T throwable,
StreamOutput out)
Serializes the given exceptions stacktrace elements as well as it's suppressed exceptions to the given output stream.
|
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
public static final java.lang.String REST_EXCEPTION_SKIP_CAUSE
public static final java.lang.String REST_EXCEPTION_SKIP_STACK_TRACE
public static final boolean REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT
public static final boolean REST_EXCEPTION_SKIP_CAUSE_DEFAULT
public ElasticsearchException(java.lang.Throwable cause)
ElasticsearchException
with the specified cause exception.public ElasticsearchException(java.lang.String msg, java.lang.Object... args)
ElasticsearchException
with the specified detail message.
The message can be parameterized using {}
as placeholders for the given
argumentsmsg
- the detail messageargs
- the arguments for the messagepublic ElasticsearchException(java.lang.String msg, java.lang.Throwable cause, java.lang.Object... args)
ElasticsearchException
with the specified detail message
and nested exception.
The message can be parameterized using {}
as placeholders for the given
argumentsmsg
- the detail messagecause
- the nested exceptionargs
- the arguments for the messagepublic ElasticsearchException(StreamInput in) throws java.io.IOException
java.io.IOException
public void addHeader(java.lang.String key, java.lang.String... value)
public void addHeader(java.lang.String key, java.util.List<java.lang.String> value)
public java.util.Set<java.lang.String> getHeaderKeys()
public java.util.List<java.lang.String> getHeader(java.lang.String key)
null
if not header for the
given key exists.public RestStatus status()
public java.lang.Throwable unwrapCause()
ElasticsearchWrapperException
.ExceptionsHelper.unwrapCause(Throwable)
public java.lang.String getDetailedMessage()
public java.lang.Throwable getRootCause()
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
public static ElasticsearchException readException(StreamInput input, int id) throws java.io.IOException
java.io.IOException
public static boolean isRegistered(java.lang.Class<? extends java.lang.Throwable> exception)
true
iff the given class is a registered for an exception to be read.public static int getId(java.lang.Class<? extends ElasticsearchException> exception)
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
protected void innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
protected void causeToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
protected final void renderHeader(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
public static void toXContent(XContentBuilder builder, ToXContent.Params params, java.lang.Throwable ex) throws java.io.IOException
ElasticsearchException
instances as XContent.java.io.IOException
public ElasticsearchException[] guessRootCauses()
public static ElasticsearchException[] guessRootCauses(java.lang.Throwable t)
ElasticsearchException
an empty array
is returned.protected java.lang.String getExceptionName()
public static java.lang.String getExceptionName(java.lang.Throwable ex)
public java.lang.String toString()
toString
in class java.lang.Throwable
public static <T extends java.lang.Throwable> T readStackTrace(T throwable, StreamInput in) throws java.io.IOException
java.io.IOException
public static <T extends java.lang.Throwable> T writeStackTraces(T throwable, StreamOutput out) throws java.io.IOException
java.io.IOException
public Index getIndex()
public ShardId getShardId()
public void setIndex(Index index)
public void setIndex(java.lang.String index)
public void setShard(ShardId shardId)
public void setShard(java.lang.String index, int shardId)
public void setResources(java.lang.String type, java.lang.String... id)
public java.util.List<java.lang.String> getResourceId()
public java.lang.String getResourceType()
public static void renderException(XContentBuilder builder, ToXContent.Params params, java.lang.Exception e) throws java.io.IOException
java.io.IOException