almost correct errors
This commit is contained in:
parent
82aff37054
commit
8e499a1735
@ -308,6 +308,7 @@ impl Web3ProxyApp {
|
|||||||
response
|
response
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
// TODO: move this to a helper function?
|
||||||
let code;
|
let code;
|
||||||
let message: String;
|
let message: String;
|
||||||
let data;
|
let data;
|
||||||
|
@ -4,6 +4,8 @@ mod connection;
|
|||||||
mod connections;
|
mod connections;
|
||||||
mod jsonrpc;
|
mod jsonrpc;
|
||||||
|
|
||||||
|
use jsonrpc::{JsonRpcErrorData, JsonRpcForwardedResponse};
|
||||||
|
use serde_json::value::RawValue;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::sync::atomic::{self, AtomicUsize};
|
use std::sync::atomic::{self, AtomicUsize};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -72,11 +74,24 @@ fn handle_anyhow_errors<T: warp::Reply>(
|
|||||||
) -> warp::http::Response<warp::hyper::Body> {
|
) -> warp::http::Response<warp::hyper::Body> {
|
||||||
match res {
|
match res {
|
||||||
Ok(r) => r.into_response(),
|
Ok(r) => r.into_response(),
|
||||||
Err(e) => warp::reply::with_status(
|
Err(e) => {
|
||||||
// TODO: json error
|
let e = JsonRpcForwardedResponse {
|
||||||
format!("{}", e),
|
jsonrpc: "2.0".to_string(),
|
||||||
|
// TODO: what id can we use? how do we make sure it gets attached to this?
|
||||||
|
id: RawValue::from_string("0".to_string()).unwrap(),
|
||||||
|
result: None,
|
||||||
|
error: Some(JsonRpcErrorData {
|
||||||
|
code: -32099,
|
||||||
|
message: format!("{:?}", e),
|
||||||
|
data: None,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
warp::reply::with_status(
|
||||||
|
serde_json::to_string(&e).unwrap(),
|
||||||
warp::http::StatusCode::INTERNAL_SERVER_ERROR,
|
warp::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
.into_response(),
|
.into_response(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user