diff --git a/bin/chat-cli/src/main.rs b/bin/chat-cli/src/main.rs index 9a35b45..b36dbe3 100644 --- a/bin/chat-cli/src/main.rs +++ b/bin/chat-cli/src/main.rs @@ -119,6 +119,7 @@ fn run(transport: T, cli: &Cli) -> Result<()> { let (client, events) = ChatClientBuilder::new() .transport(transport) .storage_config(storage) + .map_err(|e| anyhow::anyhow!("{e:?}"))? .registration(registry) .build() .map_err(|e| anyhow::anyhow!("{e:?}")) @@ -129,6 +130,7 @@ fn run(transport: T, cli: &Cli) -> Result<()> { let (client, events) = ChatClientBuilder::new() .transport(transport) .storage_config(storage) + .map_err(|e| anyhow::anyhow!("{e:?}"))? .build() .map_err(|e| anyhow::anyhow!("{e:?}")) .context("failed to open chat client")?; @@ -197,6 +199,7 @@ fn run_logos_delivery(cli: Cli) -> Result<()> { path: db_str, key: "chat-cli".to_string(), }) + .map_err(|e| anyhow::anyhow!("{e:?}"))? .transport(delivery) .build() .map_err(|e| anyhow::anyhow!("{e:?}")) diff --git a/crates/client/src/builder.rs b/crates/client/src/builder.rs index e093dfe..c9dae6b 100644 --- a/crates/client/src/builder.rs +++ b/crates/client/src/builder.rs @@ -74,17 +74,18 @@ impl ChatClientBuilder { } } - pub fn storage_config(self, config: StorageConfig) -> ChatClientBuilder { - let storage = ChatStorage::new(config) - .map_err(ChatError::from) - .expect("Storage config file should be valid"); + pub fn storage_config( + self, + config: StorageConfig, + ) -> Result, ChatError> { + let storage = ChatStorage::new(config).map_err(ChatError::from)?; - ChatClientBuilder { + Ok(ChatClientBuilder { ident: self.ident, transport: self.transport, registration: self.registration, storage, - } + }) } } diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index becf852..d8b8f40 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -14,7 +14,7 @@ pub use event::{Event, MessageSender}; // Re-export types callers need to interact with ChatClient. pub use libchat::{ - AddressedEnvelope, ChatStore, ConversationClass, ConversationId, DeliveryService, + AddressedEnvelope, ChatStorage, ChatStore, ConversationClass, ConversationId, DeliveryService, IdentityProvider, RegistrationService, StorageConfig, };