Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit d98d283

Browse files
authored
VG-750 fix(explorer): Return explorer error in broadcast error message (#936)
1 parent f5b1422 commit d98d283

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

core/idl/errors.djinni

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ ErrorCode = enum {
108108

109109
# Tezos errors
110110
invalid_self_tx;
111+
112+
# Exolorer errors
113+
explorer_error;
111114
}
112115

113116
Error = record {

core/src/api/ErrorCode.cpp

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/api/ErrorCode.hpp

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/src/wallet/bitcoin/explorers/LedgerApiBitcoinLikeBlockchainExplorer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ namespace ledger {
6262
return _http->POST(fmt::format("/blockchain/{}/{}/transactions/send", getExplorerVersion(), getNetworkParameters().Identifier),
6363
std::vector<uint8_t>(bodyString.begin(), bodyString.end()),
6464
headers)
65-
.json()
65+
.json(false, true, false)
6666
.template map<String>(getExplorerContext(), [](const HttpRequest::JsonResult &result) -> String {
6767
auto &json = *std::get<1>(result);
68+
if (!json.HasMember("result")) {
69+
throw Exception(api::ErrorCode::EXPLORER_ERROR, fmt::format("Got explorer error: {}", json["message"].GetString()));
70+
}
6871
return json["result"].GetString();
6972
});
7073
}
@@ -153,4 +156,4 @@ namespace ledger {
153156
}
154157

155158
} // namespace core
156-
} // namespace ledger
159+
} // namespace ledger

0 commit comments

Comments
 (0)