|
@@ -13,6 +13,7 @@ import org.elasticsearch.TransportVersions;
|
|
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
+import org.elasticsearch.rest.RestStatus;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
@@ -41,6 +42,18 @@ public class ConnectTransportException extends ActionTransportException {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * The ES REST API is a gateway to a single or multiple clusters. If there is an error connecting to other servers, then we should
|
|
|
+ * return a 502 BAD_GATEWAY status code instead of the parent class' 500 INTERNAL_SERVER_ERROR. Clients tend to retry on a 502 but not
|
|
|
+ * on a 500, and retrying may help on a connection error.
|
|
|
+ *
|
|
|
+ * @return a {@link RestStatus#BAD_GATEWAY} code
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public final RestStatus status() {
|
|
|
+ return RestStatus.BAD_GATEWAY;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void writeTo(StreamOutput out, Writer<Throwable> nestedExceptionsWriter) throws IOException {
|
|
|
super.writeTo(out, nestedExceptionsWriter);
|