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 {
|
pub fn sqlx_error_to_query_err(err: sqlx::Error) -> DbErr {
|
||||||
DbErr::Query(err.to_string())
|
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;
|
use sqlx::ConnectOptions;
|
||||||
opt.disable_statement_logging();
|
opt.disable_statement_logging();
|
||||||
}
|
}
|
||||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
match options.pool_options().connect_with(opt).await {
|
||||||
Ok(DatabaseConnection::SqlxMySqlPoolConnection(
|
Ok(pool) => Ok(DatabaseConnection::SqlxMySqlPoolConnection(
|
||||||
SqlxMySqlPoolConnection { pool },
|
SqlxMySqlPoolConnection { pool },
|
||||||
))
|
)),
|
||||||
} else {
|
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,11 @@ impl SqlxPostgresConnector {
|
|||||||
use sqlx::ConnectOptions;
|
use sqlx::ConnectOptions;
|
||||||
opt.disable_statement_logging();
|
opt.disable_statement_logging();
|
||||||
}
|
}
|
||||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
match options.pool_options().connect_with(opt).await {
|
||||||
Ok(DatabaseConnection::SqlxPostgresPoolConnection(
|
Ok(pool) => Ok(DatabaseConnection::SqlxPostgresPoolConnection(
|
||||||
SqlxPostgresPoolConnection { pool },
|
SqlxPostgresPoolConnection { pool },
|
||||||
))
|
)),
|
||||||
} else {
|
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,11 @@ impl SqlxSqliteConnector {
|
|||||||
if options.get_max_connections().is_none() {
|
if options.get_max_connections().is_none() {
|
||||||
options.max_connections(1);
|
options.max_connections(1);
|
||||||
}
|
}
|
||||||
if let Ok(pool) = options.pool_options().connect_with(opt).await {
|
match options.pool_options().connect_with(opt).await {
|
||||||
Ok(DatabaseConnection::SqlxSqlitePoolConnection(
|
Ok(pool) => Ok(DatabaseConnection::SqlxSqlitePoolConnection(
|
||||||
SqlxSqlitePoolConnection { pool },
|
SqlxSqlitePoolConnection { pool },
|
||||||
))
|
)),
|
||||||
} else {
|
Err(e) => Err(sqlx_error_to_conn_err(e)),
|
||||||
Err(DbErr::Conn("Failed to connect.".to_owned()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user