From ab7cb3df119c58015366d86f7199929176e218ef Mon Sep 17 00:00:00 2001 From: junderw Date: Fri, 29 Sep 2023 22:54:18 -0700 Subject: [PATCH] Fix: Make error messages clearer --- src/electrum/server.rs | 5 ++++- src/errors.rs | 11 ++++++++--- src/new_index/schema.rs | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/electrum/server.rs b/src/electrum/server.rs index 167532d5..6c18aadb 100644 --- a/src/electrum/server.rs +++ b/src/electrum/server.rs @@ -614,7 +614,10 @@ fn get_history( ) -> Result)>> { // to avoid silently trunacting history entries, ask for one extra more than the limit and fail if it exists let history_txids = query.history_txids(scripthash, txs_limit + 1); - ensure!(history_txids.len() <= txs_limit, ErrorKind::TooPopular); + ensure!( + history_txids.len() <= txs_limit, + ErrorKind::TooManyTxs(txs_limit) + ); Ok(history_txids) } diff --git a/src/errors.rs b/src/errors.rs index cec50cce..48274fbb 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -14,9 +14,14 @@ error_chain! { display("Iterrupted by signal {}", sig) } - TooPopular { - description("Too many history entries") - display("Too many history entries") + TooManyUtxos(limit: usize) { + description("Too many unspent transaction outputs. Contact support to raise limits.") + display("Too many unspent transaction outputs (>{}). Contact support to raise limits.", limit) + } + + TooManyTxs(limit: usize) { + description("Too many history transactions. Contact support to raise limits.") + display("Too many history transactions (>{}). Contact support to raise limits.", limit) } #[cfg(feature = "electrum-discovery")] diff --git a/src/new_index/schema.rs b/src/new_index/schema.rs index f3eccc9c..318b6209 100644 --- a/src/new_index/schema.rs +++ b/src/new_index/schema.rs @@ -671,7 +671,7 @@ impl ChainQuery { // abort if the utxo set size excedees the limit at any point in time if utxos.len() > limit { - bail!(ErrorKind::TooPopular) + bail!(ErrorKind::TooManyUtxos(limit)) } }