Browse Source
- Retrieve the last sorting index by reversing the sorting order. - Obtain the index mapping using pattern matching - Add the extension for obtaining ES error messagespull/1556/head
9 changed files with 137 additions and 145 deletions
@ -0,0 +1,32 @@ |
|||
using Elastic.Transport.Products.Elasticsearch; |
|||
using System.Text; |
|||
|
|||
namespace Elastic.Clients.Elasticsearch; |
|||
|
|||
public static class ElasticsearchResponseErrorExtensions |
|||
{ |
|||
public static bool TryGetErrorMessage(this ElasticsearchResponse response, out string? errorMessage) |
|||
{ |
|||
if (!response.IsSuccess()) |
|||
{ |
|||
var errorBuilder = new StringBuilder(); |
|||
if (response.TryGetOriginalException(out var ex) && ex != null) |
|||
{ |
|||
errorBuilder.AppendLine(ex.Message); |
|||
} |
|||
if (response.TryGetElasticsearchServerError(out var error) && error != null) |
|||
{ |
|||
errorBuilder.AppendLine(error.ToString()); |
|||
} |
|||
|
|||
if (errorBuilder.Length == 0) |
|||
{ |
|||
errorBuilder.AppendLine(response.DebugInformation); |
|||
} |
|||
errorMessage = errorBuilder.ToString(); |
|||
return true; |
|||
} |
|||
errorMessage = null; |
|||
return false; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue