New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generify Index and Shard exceptions #12023
Generify Index and Shard exceptions #12023
Conversation
@@ -89,16 +91,18 @@ public ElasticsearchException(StreamInput in) throws IOException { | |||
* Adds a new header with the given key. | |||
* This method will replace existing header if a header with the same key already exists | |||
*/ | |||
public void addHeader(String key, String... value) { | |||
public ElasticsearchException addHeader(String key, String... value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! thank you.
this is a great start! left some comments |
I added a new commit @uboness |
} | ||
|
||
private static final String INDEX_HEADER_KEY = "es.internal.index"; | ||
private static final String SHARD_HEADER_KEY = "es.internal.shard"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe remove the internal
here?
I went through this and left some comments here and there. My main concern is that we are inconsistent in using IndexNotFoundException and it's base class ResourceNotFoundException (with it's index set). I think we should make a choice and be consistent. I tend to using a dedicated IndexNotFoundException. I think it will make the code easier to read. |
} | ||
|
||
public void setIndex(Index index) { | ||
if (index != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if index == null, do we want to clear the header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
Thx @s1monw . Left some minor comments which I don't think merit another round. LGTM. |
68a1791
to
9174db9
Compare
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`
9174db9
to
7db293c
Compare
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
orIndexShardMissingException
in favour ofResourceNotFoundException