Skip to content
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

Merged
merged 1 commit into from Jul 14, 2015

Conversation

s1monw
Copy link
Contributor

@s1monw s1monw commented Jul 3, 2015

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

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! thank you.

@uboness
Copy link
Contributor

uboness commented Jul 3, 2015

this is a great start! left some comments

@s1monw
Copy link
Contributor Author

s1monw commented Jul 6, 2015

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";
Copy link
Member

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?

@bleskes
Copy link
Contributor

bleskes commented Jul 7, 2015

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.

@s1monw
Copy link
Contributor Author

s1monw commented Jul 14, 2015

@bleskes @uboness I pushed new commits

}

public void setIndex(Index index) {
if (index != null) {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no

@bleskes
Copy link
Contributor

bleskes commented Jul 14, 2015

Thx @s1monw . Left some minor comments which I don't think merit another round. LGTM.

@s1monw s1monw force-pushed the add_resource_not_found_exception branch 2 times, most recently from 68a1791 to 9174db9 Compare July 14, 2015 14:24
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`
@s1monw s1monw force-pushed the add_resource_not_found_exception branch from 9174db9 to 7db293c Compare July 14, 2015 14:31
@s1monw s1monw merged commit 7db293c into elastic:master Jul 14, 2015
@s1monw s1monw deleted the add_resource_not_found_exception branch July 14, 2015 14:42
@lcawl lcawl added :Core/Infra/Core Core issues without another label and removed :Exceptions labels Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking :Core/Infra/Core Core issues without another label v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants