/// <summary> /// Checks the response. /// </summary> /// <param name="res">The resource.</param> /// <exception cref="MKCommandException"></exception> /// <exception cref="MikrotikDotNet.Exceptions.MKCommandException"></exception> private void checkResponse(List <string> res) { var firstRow = res[0]; if (firstRow.StartsWith("!trap") || firstRow.StartsWith("!fatal")) { var rowData = RowParser.Parse(firstRow); var exMessage = ""; //if (MKResponseParser.HasField("category", firstRow)) CommandFailureTypes errorCategory = CommandFailureTypes.GeneralFailure; if (rowData.ContainsKey("category")) { var cat = int.Parse(rowData["category"]); exMessage = "Category: " + (CommandFailureTypes)cat; errorCategory = (CommandFailureTypes)cat; } exMessage += "\n" + rowData["message"]; throw new MKCommandException(exMessage, errorCategory); } res.Remove("!done"); }
public MKCommandException(string message, CommandFailureTypes errorCategory) : this(message) { this.ErrorCategory = errorCategory; }