Skip to content

Commit

Permalink
VG-750 fix(explorer): Return explorer error in broadcast error message (
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandD committed May 31, 2023
1 parent f5b1422 commit d98d283
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions core/idl/errors.djinni
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ ErrorCode = enum {

# Tezos errors
invalid_self_tx;

# Exolorer errors
explorer_error;
}

Error = record {
Expand Down
5 changes: 4 additions & 1 deletion core/src/api/ErrorCode.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/src/api/ErrorCode.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ namespace ledger {
return _http->POST(fmt::format("/blockchain/{}/{}/transactions/send", getExplorerVersion(), getNetworkParameters().Identifier),
std::vector<uint8_t>(bodyString.begin(), bodyString.end()),
headers)
.json()
.json(false, true, false)
.template map<String>(getExplorerContext(), [](const HttpRequest::JsonResult &result) -> String {
auto &json = *std::get<1>(result);
if (!json.HasMember("result")) {
throw Exception(api::ErrorCode::EXPLORER_ERROR, fmt::format("Got explorer error: {}", json["message"].GetString()));
}
return json["result"].GetString();
});
}
Expand Down Expand Up @@ -153,4 +156,4 @@ namespace ledger {
}

} // namespace core
} // namespace ledger
} // namespace ledger

0 comments on commit d98d283

Please sign in to comment.