-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,6 @@ | |
import org.elasticsearch.common.Nullable; | ||
import org.elasticsearch.common.logging.ESLogger; | ||
import org.elasticsearch.common.logging.Loggers; | ||
import org.elasticsearch.index.Index; | ||
import org.elasticsearch.index.IndexException; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
|
@@ -240,12 +238,12 @@ public static ShardOperationFailedException[] groupBy(ShardOperationFailedExcept | |
|
||
static class GroupBy { | ||
final String reason; | ||
final Index index; | ||
final String index; | ||
final Class<? extends Throwable> causeType; | ||
|
||
public GroupBy(Throwable t) { | ||
if (t instanceof IndexException) { | ||
index = ((IndexException) t).index(); | ||
if (t instanceof ElasticsearchException) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is great |
||
index = ((ElasticsearchException) t).getIndex(); | ||
} else { | ||
index = null; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,31 +16,32 @@ | |
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.index; | ||
package org.elasticsearch; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.index.shard.IndexShardException; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* | ||
* Generic ResourceNotFoundException corresponding to the {@link RestStatus#NOT_FOUND} status code | ||
*/ | ||
public class IndexShardMissingException extends IndexShardException { | ||
public class ResourceNotFoundException extends ElasticsearchException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe we should also have a a |
||
|
||
public ResourceNotFoundException(String msg, Object... args) { | ||
super(msg, args); | ||
} | ||
|
||
public IndexShardMissingException(ShardId shardId) { | ||
super(shardId, "missing"); | ||
protected ResourceNotFoundException(String msg, Throwable cause, Object... args) { | ||
super(msg, cause, args); | ||
} | ||
|
||
public IndexShardMissingException(StreamInput in) throws IOException{ | ||
public ResourceNotFoundException(StreamInput in) throws IOException { | ||
super(in); | ||
} | ||
|
||
@Override | ||
public RestStatus status() { | ||
public final RestStatus status() { | ||
return RestStatus.NOT_FOUND; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ | |
|
||
package org.elasticsearch.action; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.index.shard.IndexShardException; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.rest.RestStatus; | ||
|
||
|
@@ -29,18 +29,19 @@ | |
/** | ||
* | ||
*/ | ||
public class NoShardAvailableActionException extends IndexShardException { | ||
public class NoShardAvailableActionException extends ElasticsearchException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to make this a ResourceNotAvailableException? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'love this but I think it's worth another change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
|
||
public NoShardAvailableActionException(ShardId shardId) { | ||
super(shardId, null); | ||
this(shardId, null); | ||
} | ||
|
||
public NoShardAvailableActionException(ShardId shardId, String msg) { | ||
super(shardId, msg); | ||
this(shardId, msg, null); | ||
} | ||
|
||
public NoShardAvailableActionException(ShardId shardId, String msg, Throwable cause) { | ||
super(shardId, msg, cause); | ||
super(msg, cause); | ||
setShard(shardId); | ||
} | ||
|
||
@Override | ||
|
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