2021-11-20 08:35:04 +08:00

12 lines
384 B
Rust

use backend_service::errors::{ErrorCode, ServerError};
use sqlx::{Error, Postgres, Transaction};
pub type DBTransaction<'a> = Transaction<'a, Postgres>;
pub fn map_sqlx_error(error: sqlx::Error) -> ServerError {
match error {
Error::RowNotFound => ServerError::new("".to_string(), ErrorCode::RecordNotFound),
_ => ServerError::internal().context(error),
}
}