Improve startup error handling for SurrealCS connection pool (#4733)

Co-authored-by: Tobie Morgan Hitchcock <tobie@surrealdb.com>
This commit is contained in:
Maxwell Flitton 2024-09-10 20:44:04 +01:00 committed by GitHub
parent b7583a653a
commit d317a0033d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -72,8 +72,12 @@ impl Drop for Transaction {
impl Datastore { impl Datastore {
/// Open a new database /// Open a new database
pub(crate) async fn new(path: &str) -> Result<Datastore, Error> { pub(crate) async fn new(path: &str) -> Result<Datastore, Error> {
create_connection_pool(path, None).await.unwrap(); match create_connection_pool(path, None).await {
Ok(Datastore {}) Ok(_) => Ok(Datastore {}),
Err(_) => {
Err(Error::Ds("Cannot connect to the `surrealcs` storage engine".to_string()))
}
}
} }
/// Starts a new transaction. /// Starts a new transaction.