mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
Made async functions work!
- Cleaned up imports - Moved ApiError and such to it's own error.rs - Obsoleted 'success_response' in favour of new async regular and json only flavours - Made ApiError work async and be derived from hyper errors - Added a check to ensure an error is thrown if a non-json encoding is requested on a json-only function - Made all the individual service functions return futures (only node and network for now)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::BoxFut;
|
||||
use hyper::{Body, Method, Request, Response, Server, StatusCode};
|
||||
use std::error::Error as StdError;
|
||||
|
||||
@@ -37,6 +38,12 @@ impl Into<Response<Body>> for ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<BoxFut> for ApiError {
|
||||
fn into(self) -> BoxFut {
|
||||
Box::new(futures::future::err(self))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<store::Error> for ApiError {
|
||||
fn from(e: store::Error) -> ApiError {
|
||||
ApiError::ServerError(format!("Database error: {:?}", e))
|
||||
@@ -55,6 +62,12 @@ impl From<state_processing::per_slot_processing::Error> for ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<hyper::error::Error> for ApiError {
|
||||
fn from(e: hyper::error::Error) -> ApiError {
|
||||
ApiError::ServerError(format!("Networking error: {:?}", e))
|
||||
}
|
||||
}
|
||||
|
||||
impl StdError for ApiError {
|
||||
fn cause(&self) -> Option<&StdError> {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user