/// <summary> /// Parse an error message to create a NeotysAPIException. </summary> /// <param name="errorMessage"> /// @return </param> public static NeotysAPIException Parse(string errorMessage) { if (System.String.IsNullOrEmpty(errorMessage)) { return(new NeotysAPIException(ErrorType.NL_API_ERROR, "")); } if (errorMessage.Contains(BEGIN_DETAILS) && errorMessage.Contains(END_DETAILS)) { string strErrorType = errorMessage.Substring(0, errorMessage.IndexOf(BEGIN_DETAILS, StringComparison.Ordinal)); ErrorType errorTypeLocal = ErrorType.fromString(strErrorType); int detailBegin = errorMessage.IndexOf(BEGIN_DETAILS) + 1; int detailLength = errorMessage.Length - 1 - detailBegin; string strErrorDetails = errorMessage.Substring(detailBegin, detailLength); return(new NeotysAPIException(errorTypeLocal, strErrorDetails)); } ErrorType errorType = ErrorType.fromString(errorMessage); return(new NeotysAPIException(errorType, "")); }