Added support for "errors" in addition to "error". #12
the build was successful Details

This commit is contained in:
tastytea 2019-04-15 03:07:04 +02:00
parent e86019f41f
commit f84a272f53
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 9 additions and 2 deletions

View File

@ -69,7 +69,7 @@ void Easy::Entity::from_string(const string &json)
ttdebug << "ERROR: JSON string holds no object\n"; ttdebug << "ERROR: JSON string holds no object\n";
ttdebug << "String was: " << json << '\n'; ttdebug << "String was: " << json << '\n';
} }
else if (!_tree["error"].isNull()) else if (!_tree["error"].isNull() || !_tree["errors"].isNull())
{ {
ttdebug << "ERROR: Server returned an error\n"; ttdebug << "ERROR: Server returned an error\n";
ttdebug << "String was: " << json << '\n'; ttdebug << "String was: " << json << '\n';
@ -107,7 +107,14 @@ bool Easy::Entity::check_valid(const std::vector<string> &attributes) const
const string Easy::Entity::error() const const string Easy::Entity::error() const
{ {
return get_string("error"); string error = get_string("error");
if (error.empty())
{
// Pleroma uses {"errors":{"detail":"[…]"}} sometimes.
const Json::Value node = get("errors.detail");
error = node.asString();
}
return error;
} }
bool Easy::Entity::was_set() const bool Easy::Entity::was_set() const