@@ -18,6 +18,7 @@ use std::io::{Read, Write};
18
18
19
19
use clarity:: vm:: costs:: ExecutionCost ;
20
20
use regex:: { Captures , Regex } ;
21
+ use serde_json:: json;
21
22
use stacks_common:: codec:: { StacksMessageCodec , MAX_PAYLOAD_LEN } ;
22
23
use stacks_common:: types:: chainstate:: {
23
24
BlockHeaderHash , ConsensusHash , StacksBlockId , StacksPublicKey ,
@@ -118,13 +119,7 @@ impl RPCPostFeeRateRequestHandler {
118
119
let scalar_cost =
119
120
metric. from_cost_and_len ( & estimated_cost, & stacks_epoch. block_limit , estimated_len) ;
120
121
let fee_rates = fee_estimator. get_rate_estimates ( ) . map_err ( |e| {
121
- StacksHttpResponse :: new_error (
122
- preamble,
123
- & HttpBadRequest :: new ( format ! (
124
- "Estimator RPC endpoint failed to estimate fees for tx: {:?}" ,
125
- & e
126
- ) ) ,
127
- )
122
+ StacksHttpResponse :: new_error ( preamble, & HttpBadRequest :: new_json ( e. into_json ( ) ) )
128
123
} ) ?;
129
124
130
125
let mut estimations = RPCFeeEstimate :: estimate_fees ( scalar_cost, fee_rates) . to_vec ( ) ;
@@ -243,11 +238,7 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
243
238
. map_err ( |e| {
244
239
StacksHttpResponse :: new_error (
245
240
& preamble,
246
- & HttpBadRequest :: new ( format ! (
247
- "Estimator RPC endpoint failed to estimate tx {}: {:?}" ,
248
- & tx. name( ) ,
249
- & e
250
- ) ) ,
241
+ & HttpBadRequest :: new_json ( e. into_json ( ) ) ,
251
242
)
252
243
} ) ?;
253
244
@@ -263,9 +254,9 @@ impl RPCRequestHandler for RPCPostFeeRateRequestHandler {
263
254
debug ! ( "Fee and cost estimation not configured on this stacks node" ) ;
264
255
Err ( StacksHttpResponse :: new_error (
265
256
& preamble,
266
- & HttpBadRequest :: new (
267
- "Fee estimation not supported on this node" . to_string ( ) ,
268
- ) ,
257
+ & HttpBadRequest :: new_json ( json ! (
258
+ "Fee estimation not supported on this node"
259
+ ) ) ,
269
260
) )
270
261
}
271
262
} ) ;
0 commit comments