Skip to content

Added errorMessage to error message parsing #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Connection/RESTConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ public string GetErrorMessage(string error)
return deserializedObject["message"];
}

if ((deserializedObject as Dictionary<string, object>).ContainsKey("errorMessage"))
{
return deserializedObject["errorMessage"];
}

return "Unknown error";
}
#endregion
Expand Down
9 changes: 9 additions & 0 deletions Tests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@ public void GetErrorFromMessage()
string errorMessage = restConnector.GetErrorMessage(json);
Assert.IsTrue(errorMessage == "string");
}

[Test]
public void GetErrorFromErrorMessage()
{
string json = "{\"code\":\"string\",\"errorMessage\":\"string\"}";
RESTConnector restConnector = new RESTConnector();
string errorMessage = restConnector.GetErrorMessage(json);
Assert.IsTrue(errorMessage == "string");
}
}
}