diff options
author | Simon Willnauer <simonw@apache.org> | 2015-07-03 15:40:09 +0200 |
---|---|---|
committer | Simon Willnauer <simonw@apache.org> | 2015-07-14 16:31:49 +0200 |
commit | 7db293c6167179bd470bb8a189223fcb67c0fae1 (patch) | |
tree | 5275a0b0cb4e49d7b31659cb254c34510283d27c /core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java | |
parent | c6b110c6ef3004807f9257b68385c3d2e52635d5 (diff) |
Generify Index and Shard exceptions
Today we have a intermediate hierarchy for shard and index exceptions
which makes it hard to introduce generic exceptions like ResourceNotFoundException
intoduced in this commit. This commit breaks up the hierarchy by adding index and shard
as a special internal header that gets rendered for every exception that fills that header.
This commit removes dedicated exceptions like `IndexMissingException` or
`IndexShardMissingException` in favour of `ResourceNotFoundException`
Diffstat (limited to 'core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java b/core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java index 0cde08f43c..31c235e09e 100644 --- a/core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java +++ b/core/src/main/java/org/elasticsearch/index/shard/IllegalIndexShardStateException.java @@ -19,6 +19,8 @@ package org.elasticsearch.index.shard; +import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.rest.RestStatus; @@ -28,17 +30,17 @@ import java.io.IOException; /** * */ -public class IllegalIndexShardStateException extends IndexShardException { +public class IllegalIndexShardStateException extends ElasticsearchException { private final IndexShardState currentState; public IllegalIndexShardStateException(ShardId shardId, IndexShardState currentState, String msg) { - super(shardId, "CurrentState[" + currentState + "] " + msg); - this.currentState = currentState; + this(shardId, currentState, msg, null); } public IllegalIndexShardStateException(ShardId shardId, IndexShardState currentState, String msg, Throwable ex) { - super(shardId, "CurrentState[" + currentState + "] ", ex); + super("CurrentState[" + currentState + "] " + msg, ex); + setShard(shardId); this.currentState = currentState; } @@ -46,11 +48,6 @@ public class IllegalIndexShardStateException extends IndexShardException { return currentState; } - @Override - public RestStatus status() { - return RestStatus.NOT_FOUND; - } - public IllegalIndexShardStateException(StreamInput in) throws IOException{ super(in); currentState = IndexShardState.fromId(in.readByte()); @@ -61,4 +58,9 @@ public class IllegalIndexShardStateException extends IndexShardException { super.writeTo(out); out.writeByte(currentState.id()); } + + @Override + public RestStatus status() { + return RestStatus.NOT_FOUND; + } } |