//iffy side effect assignment to exceptionType needed so that we simply return message to the //base constructor. private static string ParseError(ElasticsearchServerError error) { if (error == null) return _couldNotParseServerException; if (error.Error.IsNullOrEmpty()) return _couldNotParseServerException; var matches = ExceptionSplitter.Match(error.Error); if (matches.Groups.Count != 3) return _couldNotParseServerException; error.ExceptionType = matches.Groups[1].Value; return matches.Groups[2].Value; }
public ElasticsearchServerException(ElasticsearchServerError error) : base(ParseError(error)) { this.Status = error.Status; this.ExceptionType = error.ExceptionType; }