diff --git a/core/src/db/mod.rs b/core/src/db/mod.rs index b6aa33267..02486a77b 100644 --- a/core/src/db/mod.rs +++ b/core/src/db/mod.rs @@ -9,22 +9,18 @@ pub enum DatabaseError { MissingConnection, #[error("Unable find current_library in the client config")] MalformedConfig, - #[error("Unable to initialise the Prisma client")] + #[error("Unable to initialize the Prisma client")] ClientError(#[from] prisma::NewClientError), } pub async fn create_connection() -> Result { let config = state::client::get(); - let current_library = config - .libraries - .iter() - .find(|l| l.library_uuid == config.current_library_uuid) - .ok_or(DatabaseError::MalformedConfig)?; + let current_library = config.get_current_library(); let path = current_library.library_path.clone(); - // TODO: Error handling when brendan adds it to prisma-client-rust let client = prisma::new_client_with_url(&format!("file:{}", &path)).await?; + Ok(client) } diff --git a/core/src/state/client.rs b/core/src/state/client.rs index 403c6cb0c..2770a319e 100644 --- a/core/src/state/client.rs +++ b/core/src/state/client.rs @@ -76,8 +76,6 @@ impl ClientState { let file = fs::File::open(config_path)?; let reader = BufReader::new(file); let data = serde_json::from_reader(reader)?; - - println!("data:::: {:?}", data); // assign to self *self = data; Ok(())