don't panic if param is not set
This commit is contained in:
parent
d7a843cdc5
commit
b480e92259
@ -1493,7 +1493,9 @@ impl Web3ProxyApp {
|
||||
match &request.params {
|
||||
Some(serde_json::Value::Array(params)) => {
|
||||
// TODO: make a struct and use serde conversion to clean this up
|
||||
if params.len() != 1 || !params[0].is_string() {
|
||||
if params.len() != 1
|
||||
|| !params.get(0).map(|x| x.is_string()).unwrap_or(false)
|
||||
{
|
||||
// TODO: what error code?
|
||||
return Ok((
|
||||
JsonRpcForwardedResponse::from_str(
|
||||
|
@ -177,7 +177,9 @@ pub async fn block_needed(
|
||||
// TODO: think about this more
|
||||
// TODO: jsonrpc has a specific code for this
|
||||
// TODO: this shouldn't be a 500. this should be a 400. 500 will make haproxy retry a bunch
|
||||
let obj = params[0]
|
||||
let obj = params
|
||||
.get_mut(0)
|
||||
.ok_or_else(|| anyhow::anyhow!("invalid format. no params"))?
|
||||
.as_object_mut()
|
||||
.ok_or_else(|| anyhow::anyhow!("invalid format"))?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user