From ebceb0d7d6e0346f91d2595b2b6c558e92da0694 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 28 Jun 2023 21:47:06 -0700 Subject: [PATCH] descriptive text on NotImplemented errors --- web3_proxy/src/app/ws.rs | 4 +++- web3_proxy/src/block_number.rs | 2 +- web3_proxy/src/errors.rs | 13 +++++++++---- web3_proxy/src/frontend/users/rpc_keys.rs | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/web3_proxy/src/app/ws.rs b/web3_proxy/src/app/ws.rs index 78d44f49..5b7d112d 100644 --- a/web3_proxy/src/app/ws.rs +++ b/web3_proxy/src/app/ws.rs @@ -335,7 +335,9 @@ impl Web3ProxyApp { ); }); } else { - return Err(Web3ProxyError::NotImplemented); + return Err(Web3ProxyError::NotImplemented( + subscribe_to.to_owned().into(), + )); } // TODO: do something with subscription_join_handle? diff --git a/web3_proxy/src/block_number.rs b/web3_proxy/src/block_number.rs index 5905d5f5..bebedc36 100644 --- a/web3_proxy/src/block_number.rs +++ b/web3_proxy/src/block_number.rs @@ -11,7 +11,7 @@ use ethers::{ }; use serde_json::json; use std::sync::Arc; -use tracing::{trace, warn}; +use tracing::{trace, warn, error}; use crate::{frontend::authorization::Authorization, rpcs::many::Web3Rpcs}; diff --git a/web3_proxy/src/errors.rs b/web3_proxy/src/errors.rs index 2365f052..066da18a 100644 --- a/web3_proxy/src/errors.rs +++ b/web3_proxy/src/errors.rs @@ -116,7 +116,8 @@ pub enum Web3ProxyError { needed: u32, }, NotFound, - NotImplemented, + #[error(ignore)] + NotImplemented(Cow<'static, str>), NoVolatileRedisDatabase, OriginRequired, #[error(ignore)] @@ -723,12 +724,16 @@ impl Web3ProxyError { }, ) } - Self::NotImplemented => { - error!("NotImplemented"); + Self::NotImplemented(msg) => { + warn!("NotImplemented: {}", msg); ( StatusCode::NOT_IMPLEMENTED, JsonRpcErrorData { - message: "work in progress".into(), + message: format!( + "{} is not yet implemented. contact us if you need this", + msg + ) + .into(), code: StatusCode::NOT_IMPLEMENTED.as_u16().into(), data: None, }, diff --git a/web3_proxy/src/frontend/users/rpc_keys.rs b/web3_proxy/src/frontend/users/rpc_keys.rs index 0ec84c70..85800bb2 100644 --- a/web3_proxy/src/frontend/users/rpc_keys.rs +++ b/web3_proxy/src/frontend/users/rpc_keys.rs @@ -128,7 +128,7 @@ pub async fn rpc_keys_delete( let (_user, _semaphore) = app.bearer_is_authorized(bearer).await?; // TODO: think about how cascading deletes and billing should work - Err(Web3ProxyError::NotImplemented) + Err(Web3ProxyError::NotImplemented("rpc_keys_delete".into())) } /// the JSON input to the `rpc_keys_management` handler.