From 9f2d4aa7317dda480a8912229af8a9b49298c480 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 8 Nov 2023 15:12:20 -0800 Subject: [PATCH] wip. different message if not premium --- web3_proxy/src/errors.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web3_proxy/src/errors.rs b/web3_proxy/src/errors.rs index db7715d0..80078825 100644 --- a/web3_proxy/src/errors.rs +++ b/web3_proxy/src/errors.rs @@ -1222,16 +1222,25 @@ impl Web3ProxyError { ) } Self::Timeout(x) => { - let data = x.as_ref().map(|x| json!(x.as_secs_f32())); + let data = if request_for_error.active_premium() { + json!({ + "duration": x.as_ref().map(|x| x.as_secs_f32()), + "request": request_for_error, + }) + } else { + json!({ + "duration": x.as_ref().map(|x| x.as_secs_f32()), + "request": request_for_error, + "extra": "upgrade to a premium rpc key for longer timeouts" + }) + }; ( StatusCode::REQUEST_TIMEOUT, JsonRpcErrorData { message: "request timed out".into(), code: StatusCode::REQUEST_TIMEOUT.as_u16().into(), - // TODO: prettier message - // TODO: include the actual id! - data, + data: Some(data), }, ) }