Detailed connection errors
This commit is contained in:
parent
64c54f8ad6
commit
da705f6629
@ -9,3 +9,8 @@ pub fn sqlx_error_to_exec_err(err: sqlx::Error) -> DbErr {
|
||||
pub fn sqlx_error_to_query_err(err: sqlx::Error) -> DbErr {
|
||||
DbErr::Query(err.to_string())
|
||||
}
|
||||
|
||||
/// Converts an [sqlx::error] connection error to a [DbErr]
|
||||
pub fn sqlx_error_to_conn_err(err: sqlx::Error) -> DbErr {
|
||||
DbErr::Conn(err.to_string())
|
||||
}
|
||||
|
@ -41,12 +41,11 @@ impl SqlxMySqlConnector {
|
||||
use sqlx::ConnectOptions;
|
||||
opt.disable_statement_logging();
|
||||
}
|
||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
||||
Ok(DatabaseConnection::SqlxMySqlPoolConnection(
|
||||
match options.pool_options().connect_with(opt).await {
|
||||
Ok(pool) => Ok(DatabaseConnection::SqlxMySqlPoolConnection(
|
||||
SqlxMySqlPoolConnection { pool },
|
||||
))
|
||||
} else {
|
||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
||||
)),
|
||||
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,11 @@ impl SqlxPostgresConnector {
|
||||
use sqlx::ConnectOptions;
|
||||
opt.disable_statement_logging();
|
||||
}
|
||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
||||
Ok(DatabaseConnection::SqlxPostgresPoolConnection(
|
||||
match options.pool_options().connect_with(opt).await {
|
||||
Ok(pool) => Ok(DatabaseConnection::SqlxPostgresPoolConnection(
|
||||
SqlxPostgresPoolConnection { pool },
|
||||
))
|
||||
} else {
|
||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
||||
)),
|
||||
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,12 +45,11 @@ impl SqlxSqliteConnector {
|
||||
if options.get_max_connections().is_none() {
|
||||
options.max_connections(1);
|
||||
}
|
||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
||||
Ok(DatabaseConnection::SqlxSqlitePoolConnection(
|
||||
match options.pool_options().connect_with(opt).await {
|
||||
Ok(pool) => Ok(DatabaseConnection::SqlxSqlitePoolConnection(
|
||||
SqlxSqlitePoolConnection { pool },
|
||||
))
|
||||
} else {
|
||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
||||
)),
|
||||
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user