Package org.elasticsearch
Class ElasticsearchException
org.elasticsearch.ElasticsearchException
- All Implemented Interfaces:
,
Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
- Direct Known Subclasses:
AggregationExecutionException
,AggregationInitializationException
,AliasFilterParsingException
,BlobStoreException
,BroadcastShardOperationFailedException
,CancellableThreads.ExecutionCancelledException
,CircuitBreakingException
,ClusterBlockException
,CoordinationStateRejectedException
,DelayRecoveryException
,ElasticsearchGenerationException
,ElasticsearchParseException
,ElasticsearchStatusException
,ElasticsearchTimeoutException
,EngineException
,FailedNodeException
,FailedToCommitClusterStateException
,GeneralScriptException
,HttpException
,IllegalIndexShardStateException
,IncompatibleClusterStateVersionException
,IndexClosedException
,IndexCreationException
,IndexPrimaryShardNotAllocatedException
,IndexShardRecoveryException
,IndexShardRestoreException
,IndexShardSnapshotException
,IndexTemplateMissingException
,IngestProcessorException
,InvalidAggregationPathException
,InvalidAliasNameException
,InvalidIndexNameException
,InvalidIndexTemplateException
,MapperException
,MasterNotDiscoveredException
,NodeClosedException
,NodeHealthCheckFailureException
,NoNodeAvailableException
,NoSeedNodeLeftException
,NoShardAvailableActionException
,NotMasterException
,NotSerializableExceptionWrapper
,ParsingException
,PrimaryMissingActionException
,ProcessClusterEventTimeoutException
,QueryShardException
,RecoverFilesRecoveryException
,RecoveryFailedException
,ReplicationOperation.RetryOnPrimaryException
,RepositoryException
,ResourceAlreadyExistsException
,ResourceNotFoundException
,RetentionLeaseInvalidRetainingSeqNoException
,RoutingException
,RoutingMissingException
,ScriptException
,SearchContextMissingException
,SearchException
,SearchPhaseExecutionException
,SearchSourceBuilderException
,SettingsException
,ShardLockObtainFailedException
,ShardStateAction.NoLongerPrimaryShardException
,SnapshotException
,SnapshotInProgressException
,TaskCancelledException
,TcpTransport.HttpRequestOnTransportException
,TimestampParsingException
,TranslogCorruptedException
,TranslogException
,TransportException
,TransportReplicationAction.RetryOnReplicaException
,TypeMissingException
,UnavailableShardsException
,UncategorizedExecutionException
,VersionMismatchException
public class ElasticsearchException
extends
implements org.elasticsearch.common.xcontent.ToXContentFragment, Writeable
A base class for all elasticsearch exceptions.
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic
Passed in theToXContent.Params
ofgenerateThrowableXContent(XContentBuilder, Params, Throwable)
to control if thestack_trace
element should render.static boolean
static
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionmsg, ... args)
Construct aElasticsearchException
with the specified detail message.msg, cause, ... args)
Construct aElasticsearchException
with the specified detail message and nested exception.cause)
Construct aElasticsearchException
with the specified cause exception. -
Method Summary
Modifier and TypeMethodDescriptionvoid
key, ... value)
Adds a new header with the given key.void
key, <> value)
Adds a new header with the given key.void
key, ... values)
Adds a new piece of metadata with the given key.void
key, <> values)
Adds a new piece of metadata with the given key.static ElasticsearchException
failureFromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Parses the output ofgenerateFailureXContent(XContentBuilder, Params, Exception, boolean)
static ElasticsearchException
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Generate aElasticsearchException
from aXContentParser
.static void
generateFailureXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, e, boolean detailed)
Render any exception as a xcontent, encapsulated within a field or object named "error".static void
generateThrowableXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, t)
Static toXContent helper method that renders instances as XContent, delegating the rendering totoXContent(XContentBuilder, Params)
orinnerToXContent(XContentBuilder, Params, Throwable, String, String, Map, Map, Throwable)
.Return the detail message, including the message from the nested exception if there is one.protected
static
ex)
Returns a underscore case name for the given exception.<>
key)
Returns the list of header values for the given key ornull
if no header for the given key exists.<>
Returns a set of all header keys on this exceptionprotected <,<>>
static int
<? extends ElasticsearchException> exception)
Returns the serialization id the given exception.getIndex()
protected <,<>>
<>
key)
Returns the list of metadata values for the given key ornull
if no metadata for the given key exists.<>
Returns a set of all metadata keys on this exception<>
Retrieve the innermost cause of this exception, if none, returns the current exception.Returns the root cause of this exception or multiple if different shards caused different exceptionsstatic ElasticsearchException[]
t)
Returns the root cause of this exception or multiple if different shards caused different exceptions.static ElasticsearchException
innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser, boolean parseRootCauses)
protected static void
innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, throwable, type, message, <,<>> headers, <,<>> metadata, cause)
static boolean
<? extends > exception, Version version)
Returnstrue
iff the given class is a registered for an exception to be read.protected void
metadataToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
Renders additional per exception information into the XContentstatic ElasticsearchException
readException(StreamInput input, int id)
static <T extends >
TreadStackTrace(T throwable, StreamInput in)
Deserializes stacktrace elements as well as suppressed exceptions from the given output stream and adds it to the given exception.void
index)
void
void
type, ... id)
void
status()
Returns the rest status code associated with this exception.toString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
Unwraps the actual cause from the exception for cases when the exception is aElasticsearchWrapperException
.static <T extends >
TwriteStackTraces(T throwable, StreamOutput out, > exceptionWriter)
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.Methods inherited from class java.lang.
, , , , , , , , , , ,
Methods inherited from class java.lang.
, , , , , , , , ,
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
REST_EXCEPTION_SKIP_STACK_TRACE
public static final REST_EXCEPTION_SKIP_STACK_TRACEPassed in theToXContent.Params
ofgenerateThrowableXContent(XContentBuilder, Params, Throwable)
to control if thestack_trace
element should render. Unlike most parameters totoXContent
methods this parameter is internal only and not available as a URL parameter. Use theerror_trace
parameter instead.- See Also:
- Constant Field Values
-
REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT
public static final boolean REST_EXCEPTION_SKIP_STACK_TRACE_DEFAULT- See Also:
- Constant Field Values
-
STACK_TRACE
public static final STACK_TRACE- See Also:
- Constant Field Values
-
-
Constructor Details
-
ElasticsearchException
public ElasticsearchException( cause)Construct aElasticsearchException
with the specified cause exception. -
ElasticsearchException
public ElasticsearchException( msg, ... args)Construct aElasticsearchException
with the specified detail message. The message can be parameterized using{}
as placeholders for the given arguments- Parameters:
msg
- the detail messageargs
- the arguments for the message
-
ElasticsearchException
public ElasticsearchException( msg, cause, ... args)Construct aElasticsearchException
with the specified detail message and nested exception. The message can be parameterized using{}
as placeholders for the given arguments- Parameters:
msg
- the detail messagecause
- the nested exceptionargs
- the arguments for the message
-
ElasticsearchException
- Throws:
-
-
Method Details
-
addMetadata
public void addMetadata( key, ... values)Adds a new piece of metadata with the given key. If the provided key is already present, the corresponding metadata will be replaced -
addMetadata
public void addMetadata( key, <> values)Adds a new piece of metadata with the given key. If the provided key is already present, the corresponding metadata will be replaced -
getMetadataKeys
public <> getMetadataKeys()Returns a set of all metadata keys on this exception -
getMetadata
public <> getMetadata( key)Returns the list of metadata values for the given key ornull
if no metadata for the given key exists. -
getMetadata
protected <,<>> getMetadata() -
addHeader
public void addHeader( key, <> value)Adds a new header with the given key. This method will replace existing header if a header with the same key already exists -
addHeader
public void addHeader( key, ... value)Adds a new header with the given key. This method will replace existing header if a header with the same key already exists -
getHeaderKeys
public <> getHeaderKeys()Returns a set of all header keys on this exception -
getHeader
public <> getHeader( key)Returns the list of header values for the given key ornull
if no header for the given key exists. -
getHeaders
protected <,<>> getHeaders() -
status
Returns the rest status code associated with this exception. -
unwrapCause
public unwrapCause()Unwraps the actual cause from the exception for cases when the exception is aElasticsearchWrapperException
.- See Also:
ExceptionsHelper.unwrapCause(Throwable)
-
getDetailedMessage
public getDetailedMessage()Return the detail message, including the message from the nested exception if there is one. -
getRootCause
public getRootCause()Retrieve the innermost cause of this exception, if none, returns the current exception. -
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
readException
- Throws:
-
isRegistered
Returnstrue
iff the given class is a registered for an exception to be read. -
getId
Returns the serialization id the given exception. -
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
-
innerToXContent
protected static void innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, throwable, type, message, <,<>> headers, <,<>> metadata, cause) throws- Throws:
-
metadataToXContent
protected void metadataToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throwsRenders additional per exception information into the XContent- Throws:
-
fromXContent
public static ElasticsearchException fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throwsGenerate aElasticsearchException
from aXContentParser
. This does not return the original exception type (ie NodeClosedException for example) but just wraps the type, the reason and the cause of the exception. It also recursively parses the tree structure of the cause, returning it as a tree structure ofElasticsearchException
instances.- Throws:
-
innerFromXContent
public static ElasticsearchException innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser, boolean parseRootCauses) throws- Throws:
-
generateThrowableXContent
public static void generateThrowableXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, t) throwsStatic toXContent helper method that renders instances as XContent, delegating the rendering totoXContent(XContentBuilder, Params)
orinnerToXContent(XContentBuilder, Params, Throwable, String, String, Map, Map, Throwable)
. This method is usually used when the is rendered as a part of another XContent object, and its result can be parsed back using thefromXContent(XContentParser)
method.- Throws:
-
generateFailureXContent
public static void generateFailureXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params, @Nullable e, boolean detailed) throwsRender any exception as a xcontent, encapsulated within a field or object named "error". The level of details that are rendered depends on the value of the "detailed" parameter: when it's false only a simple message based on the type and message of the exception is rendered. When it's true all detail are provided including guesses root causes, cause and potentially stack trace. This method is usually used when the is rendered as a full XContent object, and its output can be parsed by thefailureFromXContent(XContentParser)
method.- Throws:
-
failureFromXContent
public static ElasticsearchException failureFromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throwsParses the output ofgenerateFailureXContent(XContentBuilder, Params, Exception, boolean)
- Throws:
-
guessRootCauses
Returns the root cause of this exception or multiple if different shards caused different exceptions -
guessRootCauses
public static t)Returns the root cause of this exception or multiple if different shards caused different exceptions. If the given exception is not an instance ofElasticsearchException
an empty array is returned. -
getExceptionName
protected getExceptionName() -
getExceptionName
public static getExceptionName( ex)Returns a underscore case name for the given exception. This method stripsElasticsearch
prefixes from exception names. -
toString
public toString()- Overrides:
in class
-
readStackTrace
Deserializes stacktrace elements as well as suppressed exceptions from the given output stream and adds it to the given exception.- Throws:
-
writeStackTraces
public static <T extends > T writeStackTraces(T throwable, StreamOutput out, > exceptionWriter) throwsSerializes the given exceptions stacktrace elements as well as it's suppressed exceptions to the given output stream.- Throws:
-
getIndex
-
getShardId
-
setIndex
-
setIndex
public void setIndex( index) -
setShard
-
setResources
public void setResources( type, ... id) -
getResourceId
public <> getResourceId() -
getResourceType
public getResourceType()
-