Prettier database error messages

This commit is contained in:
Funtimes909 committed 2025-02-20 11:49:58 +13:00
1 parent acbe236580
commit b01e85a232
1 file changed
+7 -1
+7 -1
View File
@@ -4,7 +4,13 @@ use sqlx::postgres::PgQueryResult;
use crate::response::Server;
pub async fn connect(database_url: &str) -> PgConnection {
PgConnection::connect(&database_url).await.expect("Failed to connect to database!")
match PgConnection::connect(&database_url).await {
Ok(conn) => conn,
Err(error) => {
println!("Failed to connect to database: {}", error);
std::process::exit(1);
}
}
}
// TODO! Return a stream of results instead of a Vec for performance