summaryrefslogtreecommitdiff
path: root/src/client/Client.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-09-05 18:47:03 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-09-05 18:47:03 (GMT)
commit5da70ef8a633328d7441fd08c7e8592247f52f7b (patch)
treecc1f677e03cca255d461885bfd20fbbcaa47e159 /src/client/Client.cpp
parent09c266f25256d25103781e74038fc5265b957459 (diff)
downloadpowder-5da70ef8a633328d7441fd08c7e8592247f52f7b.zip
powder-5da70ef8a633328d7441fd08c7e8592247f52f7b.tar.gz
Ensure errors are caught and displayed during tag operations. Fix some issues with the Tag ui. Fixes #157
Diffstat (limited to 'src/client/Client.cpp')
-rw-r--r--src/client/Client.cpp48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/client/Client.cpp b/src/client/Client.cpp
index 852dbb6..191cebb 100644
--- a/src/client/Client.cpp
+++ b/src/client/Client.cpp
@@ -1821,15 +1821,27 @@ std::vector<std::string> * Client::RemoveTag(int saveID, std::string tag)
try
{
std::istringstream dataStream(data);
- json::Array tagsArray;
- json::Reader::Read(tagsArray, dataStream);
+ json::Object responseObject;
+ json::Reader::Read(responseObject, dataStream);
- tags = new std::vector<std::string>();
+ json::Number status = responseObject["Status"];
- for(int j = 0; j < tagsArray.Size(); j++)
+ if(status.Value()==0)
{
- json::String tempTag = tagsArray[j];
- tags->push_back(tempTag.Value());
+ json::String error = responseObject["Error"];
+ lastError = error.Value();
+ }
+ else
+ {
+ json::Array tagsArray = responseObject["Tags"];
+
+ tags = new std::vector<std::string>();
+
+ for(int j = 0; j < tagsArray.Size(); j++)
+ {
+ json::String tempTag = tagsArray[j];
+ tags->push_back(tempTag.Value());
+ }
}
}
catch (json::Exception &e)
@@ -1870,15 +1882,27 @@ std::vector<std::string> * Client::AddTag(int saveID, std::string tag)
try
{
std::istringstream dataStream(data);
- json::Array tagsArray;
- json::Reader::Read(tagsArray, dataStream);
+ json::Object responseObject;
+ json::Reader::Read(responseObject, dataStream);
- tags = new std::vector<std::string>();
+ json::Number status = responseObject["Status"];
- for(int j = 0; j < tagsArray.Size(); j++)
+ if(status.Value()==0)
{
- json::String tempTag = tagsArray[j];
- tags->push_back(tempTag.Value());
+ json::String error = responseObject["Error"];
+ lastError = error.Value();
+ }
+ else
+ {
+ json::Array tagsArray = responseObject["Tags"];
+
+ tags = new std::vector<std::string>();
+
+ for(int j = 0; j < tagsArray.Size(); j++)
+ {
+ json::String tempTag = tagsArray[j];
+ tags->push_back(tempTag.Value());
+ }
}
}
catch (json::Exception &e)