bug fixes
This commit is contained in:
@@ -541,6 +541,9 @@ impl VeilidAPI {
|
||||
NetworkResult::Timeout => {
|
||||
return Ok("Timeout".to_owned());
|
||||
}
|
||||
NetworkResult::ServiceUnavailable => {
|
||||
return Ok("ServiceUnavailable".to_owned());
|
||||
}
|
||||
NetworkResult::NoConnection(e) => {
|
||||
return Ok(format!("NoConnection({})", e));
|
||||
}
|
||||
|
@@ -8,6 +8,14 @@ macro_rules! apibail_timeout {
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! apibail_try_again {
|
||||
() => {
|
||||
return Err(VeilidAPIError::try_again())
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
#[macro_export]
|
||||
macro_rules! apibail_generic {
|
||||
@@ -95,6 +103,8 @@ pub enum VeilidAPIError {
|
||||
AlreadyInitialized,
|
||||
#[error("Timeout")]
|
||||
Timeout,
|
||||
#[error("TryAgain")]
|
||||
TryAgain,
|
||||
#[error("Shutdown")]
|
||||
Shutdown,
|
||||
#[error("Key not found: {key}")]
|
||||
@@ -131,6 +141,9 @@ impl VeilidAPIError {
|
||||
pub fn timeout() -> Self {
|
||||
Self::Timeout
|
||||
}
|
||||
pub fn try_again() -> Self {
|
||||
Self::TryAgain
|
||||
}
|
||||
pub fn shutdown() -> Self {
|
||||
Self::Shutdown
|
||||
}
|
||||
|
@@ -153,6 +153,7 @@ impl RoutingContext {
|
||||
let answer = match rpc_processor.rpc_call_app_call(dest, request).await {
|
||||
Ok(NetworkResult::Value(v)) => v,
|
||||
Ok(NetworkResult::Timeout) => apibail_timeout!(),
|
||||
Ok(NetworkResult::ServiceUnavailable) => apibail_try_again!(),
|
||||
Ok(NetworkResult::NoConnection(e)) | Ok(NetworkResult::AlreadyExists(e)) => {
|
||||
apibail_no_connection!(e);
|
||||
}
|
||||
@@ -181,6 +182,7 @@ impl RoutingContext {
|
||||
match rpc_processor.rpc_call_app_message(dest, message).await {
|
||||
Ok(NetworkResult::Value(())) => {}
|
||||
Ok(NetworkResult::Timeout) => apibail_timeout!(),
|
||||
Ok(NetworkResult::ServiceUnavailable) => apibail_try_again!(),
|
||||
Ok(NetworkResult::NoConnection(e)) | Ok(NetworkResult::AlreadyExists(e)) => {
|
||||
apibail_no_connection!(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user