Skip to content

Commit 551a175

Browse files
committed
feat: add exclusion violation error kind
1 parent a0e4054 commit 551a175

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

sqlx-core/src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ pub enum ErrorKind {
197197
NotNullViolation,
198198
/// Check constraint violation.
199199
CheckViolation,
200+
/// Exclusion constraint violation.
201+
ExclusionViolation,
200202
/// An unmapped error.
201203
Other,
202204
}

sqlx-postgres/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ impl DatabaseError for PgDatabaseError {
214214
error_codes::FOREIGN_KEY_VIOLATION => ErrorKind::ForeignKeyViolation,
215215
error_codes::NOT_NULL_VIOLATION => ErrorKind::NotNullViolation,
216216
error_codes::CHECK_VIOLATION => ErrorKind::CheckViolation,
217+
error_codes::EXCLUSION_VIOLATION => ErrorKind::ExclusionViolation,
217218
_ => ErrorKind::Other,
218219
}
219220
}
@@ -239,4 +240,6 @@ pub(crate) mod error_codes {
239240
pub const NOT_NULL_VIOLATION: &str = "23502";
240241
/// Caused when a check constraint is violated.
241242
pub const CHECK_VIOLATION: &str = "23514";
243+
/// Caused when a exclude constraint is violated.
244+
pub const EXCLUSION_VIOLATION: &str = "23P01";
242245
}

0 commit comments

Comments
 (0)