|
7 | 7 |
|
8 | 8 | namespace Nest |
9 | 9 | { |
| 10 | + /// <summary> |
| 11 | + /// Shared interface by all elasticsearch responses |
| 12 | + /// </summary> |
10 | 13 | public interface IResponse : IBodyWithApiCallDetails |
11 | 14 | { |
| 15 | + /// <summary> |
| 16 | + /// This property can be used to check if a response is functionally valid or not. |
| 17 | + /// This is a NEST abstraction to have a single point to check whether something wrong happend with the request. |
| 18 | + /// <para>For instance an elasticsearch bulk response always returns 200 and individual bulk items may fail, <see cref="IsValid"/> will be false in that case</para> |
| 19 | + /// <para>You can also configure the client to always throw an <see cref="ElasticsearchClientException"/> using <see cref="IConnectionConfigurationValues.ThrowExceptions"/> if the response is not valid</para> |
| 20 | + /// </summary> |
12 | 21 | [JsonIgnore] |
13 | 22 | bool IsValid { get; } |
14 | 23 |
|
| 24 | + /// <summary> |
| 25 | + /// Returns the <see cref="IApiCallDetails"/> diagnostic information |
| 26 | + /// </summary> |
15 | 27 | [JsonIgnore] |
16 | | - IApiCallDetails ApiCall { get; } |
| 28 | + new IApiCallDetails ApiCall { get; } |
17 | 29 |
|
| 30 | + /// <summary> |
| 31 | + /// If the response results in an error on elasticsearch's side an <pre>error</pre> element will be returned, this is mapped to <see cref="ServerError"/> in NEST. |
| 32 | + /// <para>This property is a shortcut to <see cref="ApiCall"/>'s <see cref="IApiCallDetails.ServerError"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para> |
| 33 | + /// <para>You can also configure the client to always throw an <see cref="ElasticsearchClientException"/> using <see cref="IConnectionConfigurationValues.ThrowExceptions"/> if the response is not valid</para> |
| 34 | + /// </summary> |
18 | 35 | [JsonIgnore] |
19 | 36 | ServerError ServerError { get; } |
20 | 37 |
|
| 38 | + /// <summary> |
| 39 | + /// If the request resulted in an exception on the client side this will hold the exception that was thrown. |
| 40 | + /// <para>This property is a shortcut to <see cref="ApiCall"/>'s <see cref="IApiCallDetails.OriginalException"/> and is possibly set when <see cref="IsValid"/> is false depending on the cause of the error</para> |
| 41 | + /// <para>You can also configure the client to always throw an <see cref="ElasticsearchClientException"/> using <see cref="IConnectionConfigurationValues.ThrowExceptions"/> if the response is not valid</para> |
| 42 | + /// </summary> |
21 | 43 | [JsonIgnore] |
22 | 44 | Exception OriginalException { get; } |
23 | 45 |
|
| 46 | + /// <summary> |
| 47 | + /// A lazy human readable string representation of what happened during this request for both succesful and failed requests, very useful while developing or to log when you get <see cref="IsValid"/> = false responses. |
| 48 | + /// </summary> |
24 | 49 | [JsonIgnore] |
25 | 50 | string DebugInformation { get; } |
26 | 51 |
|
27 | 52 | } |
28 | 53 |
|
29 | 54 | public abstract class ResponseBase : IResponse |
30 | 55 | { |
| 56 | + /// <inheritdoc/> |
31 | 57 | public virtual bool IsValid => (this.ApiCall?.Success ?? false) && (this.ServerError == null); |
32 | 58 |
|
33 | | - IApiCallDetails IBodyWithApiCallDetails.CallDetails { get; set; } |
| 59 | + IApiCallDetails IBodyWithApiCallDetails.ApiCall { get; set; } |
34 | 60 |
|
35 | | - public virtual IApiCallDetails ApiCall => ((IBodyWithApiCallDetails)this).CallDetails; |
| 61 | + /// <inheritdoc/> |
| 62 | + public virtual IApiCallDetails ApiCall => ((IBodyWithApiCallDetails)this).ApiCall; |
36 | 63 |
|
| 64 | + /// <inheritdoc/> |
37 | 65 | public virtual ServerError ServerError => this.ApiCall?.ServerError; |
38 | 66 |
|
| 67 | + /// <inheritdoc/> |
39 | 68 | public Exception OriginalException => this.ApiCall?.OriginalException; |
40 | 69 |
|
| 70 | + /// <inheritdoc/> |
41 | 71 | public string DebugInformation |
42 | 72 | { |
43 | 73 | get |
|
0 commit comments