Skip to content

Commit 20fef8b

Browse files
committed
Add Error::unique_violation to create a non exhaustive unique_violation
1 parent 90084cd commit 20fef8b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

chuchi-postgres/src/connection.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ pub enum Error {
4949
Unknown(Box<dyn std::error::Error + Send + Sync>),
5050
}
5151

52+
impl Error {
53+
pub fn unique_violation(constraint: Option<String>) -> Self {
54+
Self::UniqueViolation { constraint }
55+
}
56+
}
57+
5258
impl From<PgError> for Error {
5359
fn from(e: PgError) -> Self {
5460
let Some(db_error) = e.as_db_error() else {

0 commit comments

Comments
 (0)