Combine Sbot and SbotInit errors
This commit is contained in:
parent
48beb4a2e5
commit
b24f2e4a06
|
@ -34,8 +34,6 @@ pub enum GolgiError {
|
||||||
Rpc(RpcError),
|
Rpc(RpcError),
|
||||||
/// Go-sbot error.
|
/// Go-sbot error.
|
||||||
Sbot(String),
|
Sbot(String),
|
||||||
/// Error initializing Go-sbot.
|
|
||||||
SbotInit(String),
|
|
||||||
/// SSB sigil-link error.
|
/// SSB sigil-link error.
|
||||||
SigilLink(String),
|
SigilLink(String),
|
||||||
/// JSON serialization or deserialization error.
|
/// JSON serialization or deserialization error.
|
||||||
|
@ -59,7 +57,6 @@ impl std::error::Error for GolgiError {
|
||||||
GolgiError::Feed(ref err) => Some(err),
|
GolgiError::Feed(ref err) => Some(err),
|
||||||
GolgiError::Rpc(ref err) => Some(err),
|
GolgiError::Rpc(ref err) => Some(err),
|
||||||
GolgiError::Sbot(_) => None,
|
GolgiError::Sbot(_) => None,
|
||||||
GolgiError::SbotInit(_) => None,
|
|
||||||
GolgiError::SigilLink(_) => None,
|
GolgiError::SigilLink(_) => None,
|
||||||
GolgiError::SerdeJson(ref err) => Some(err),
|
GolgiError::SerdeJson(ref err) => Some(err),
|
||||||
GolgiError::ContentType(_) => None,
|
GolgiError::ContentType(_) => None,
|
||||||
|
@ -80,10 +77,7 @@ impl std::fmt::Display for GolgiError {
|
||||||
// TODO: improve this variant with a context message
|
// TODO: improve this variant with a context message
|
||||||
// then have the core display msg be: "SSB RPC error: {}", context
|
// then have the core display msg be: "SSB RPC error: {}", context
|
||||||
GolgiError::Rpc(ref err) => write!(f, "SSB RPC failure: {}", err),
|
GolgiError::Rpc(ref err) => write!(f, "SSB RPC failure: {}", err),
|
||||||
GolgiError::Sbot(ref err) => write!(f, "Sbot returned an error response: {}", err),
|
GolgiError::Sbot(ref err) => write!(f, "Sbot encountered an error: {}", err),
|
||||||
GolgiError::SbotInit(ref err) => {
|
|
||||||
write!(f, "Sbot encountered an initialization error: {}", err)
|
|
||||||
}
|
|
||||||
GolgiError::SigilLink(ref context) => write!(f, "SSB blob ID error: {}", context),
|
GolgiError::SigilLink(ref context) => write!(f, "SSB blob ID error: {}", context),
|
||||||
GolgiError::SerdeJson(_) => write!(f, "Failed to serialize JSON slice"),
|
GolgiError::SerdeJson(_) => write!(f, "Failed to serialize JSON slice"),
|
||||||
//GolgiError::WhoAmI(ref err) => write!(f, "{}", err),
|
//GolgiError::WhoAmI(ref err) => write!(f, "{}", err),
|
||||||
|
|
16
src/sbot.rs
16
src/sbot.rs
|
@ -76,21 +76,21 @@ impl Sbot {
|
||||||
|
|
||||||
let OwnedIdentity { pk, sk, id } = match keystore {
|
let OwnedIdentity { pk, sk, id } = match keystore {
|
||||||
Keystore::Patchwork => keystore::from_patchwork_local().await.map_err(|_err| {
|
Keystore::Patchwork => keystore::from_patchwork_local().await.map_err(|_err| {
|
||||||
GolgiError::SbotInit(
|
GolgiError::Sbot(
|
||||||
"couldn't read local patchwork secret from default location".to_string(),
|
"sbot initialization error: couldn't read local patchwork secret from default location".to_string(),
|
||||||
)
|
)
|
||||||
})?,
|
})?,
|
||||||
Keystore::GoSbot => keystore::from_gosbot_local().await.map_err(|_err| {
|
Keystore::GoSbot => keystore::from_gosbot_local().await.map_err(|_err| {
|
||||||
GolgiError::SbotInit(
|
GolgiError::Sbot(
|
||||||
"couldn't read local go-sbot secret from default location".to_string(),
|
"sbot initialization error: couldn't read local go-sbot secret from default location".to_string(),
|
||||||
)
|
)
|
||||||
})?,
|
})?,
|
||||||
Keystore::CustomGoSbot(key_path) => {
|
Keystore::CustomGoSbot(key_path) => {
|
||||||
keystore::from_custom_gosbot_keypath(key_path.to_string())
|
keystore::from_custom_gosbot_keypath(key_path.to_string())
|
||||||
.await
|
.await
|
||||||
.map_err(|_err| {
|
.map_err(|_err| {
|
||||||
GolgiError::SbotInit(format!(
|
GolgiError::Sbot(format!(
|
||||||
"couldn't read local go-sbot secret from: {}",
|
"sbot initialization error: couldn't read local go-sbot secret from: {}",
|
||||||
key_path
|
key_path
|
||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
|
@ -99,8 +99,8 @@ impl Sbot {
|
||||||
keystore::from_custom_patchwork_keypath(key_path.to_string())
|
keystore::from_custom_patchwork_keypath(key_path.to_string())
|
||||||
.await
|
.await
|
||||||
.map_err(|_err| {
|
.map_err(|_err| {
|
||||||
GolgiError::SbotInit(format!(
|
GolgiError::Sbot(format!(
|
||||||
"couldn't read local patchwork secret from: {}",
|
"sbot initialization error: couldn't read local patchwork secret from: {}",
|
||||||
key_path
|
key_path
|
||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
|
|
Loading…
Reference in New Issue