Skip to content

Commit

Permalink
Catch the json parsing exception then cloud auth. (vesoft-inc#2105)
Browse files Browse the repository at this point in the history
* Catch the json parsing exception then cloud auth.

* Correct.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
  • Loading branch information
Shylock-Hg and dutor authored May 7, 2020
1 parent 4902e1f commit aa7742c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/graph/CloudAuthenticator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ bool CloudAuthenticator::auth(const std::string& user, const std::string& passwo
return false;
}

auto json = folly::parseJson(result.value());
if (json["code"].asString().compare("0") != 0) {
LOG(ERROR) << "Cloud authentication failed";
try {
auto json = folly::parseJson(result.value());
if (json["code"].asString().compare("0") != 0) {
LOG(ERROR) << "Cloud authentication failed";
return false;
}
} catch (std::exception& e) {
LOG(ERROR) << "Invalid json: " << e.what();
return false;
}
return true;
Expand Down

0 comments on commit aa7742c

Please sign in to comment.