19
19
20
20
package co .elastic .clients .elasticsearch ._types ;
21
21
22
+ import co .elastic .clients .transport .http .TransportHttpClient ;
23
+
22
24
import javax .annotation .Nullable ;
23
25
24
26
/**
@@ -33,11 +35,19 @@ public class ElasticsearchException extends RuntimeException {
33
35
34
36
private final ErrorResponse response ;
35
37
private final String endpointId ;
38
+ @ Nullable
39
+ private final TransportHttpClient .Response httpResponse ;
36
40
37
- public ElasticsearchException (String endpointId , ErrorResponse response ) {
41
+ public ElasticsearchException (String endpointId , ErrorResponse response ,
42
+ @ Nullable TransportHttpClient .Response httpResponse ) {
38
43
super ("[" + endpointId + "] failed: [" + response .error ().type () + "] " + response .error ().reason ());
39
44
this .response = response ;
40
45
this .endpointId = endpointId ;
46
+ this .httpResponse = httpResponse ;
47
+ }
48
+
49
+ public ElasticsearchException (String endpointId , ErrorResponse response ) {
50
+ this (endpointId , response , null );
41
51
}
42
52
43
53
/**
@@ -68,4 +78,12 @@ public ErrorCause error() {
68
78
public int status () {
69
79
return this .response .status ();
70
80
}
81
+
82
+ /**
83
+ * The underlying http response, if available.
84
+ */
85
+ @ Nullable
86
+ public TransportHttpClient .Response httpResponse () {
87
+ return this .httpResponse ;
88
+ }
71
89
}
0 commit comments