systemprompt_database/error.rs
1//! Result alias for the database crate's public signatures.
2//!
3//! The crate returns the workspace's single repository error,
4//! [`systemprompt_traits::RepositoryError`], from every database-facing
5//! signature, including the dyn-safe `DatabaseProvider` /
6//! `DatabaseTransaction` surfaces. `sqlx::Error` converts into it through the
7//! SQLSTATE classification enabled by the traits crate's `sqlx` feature.
8//!
9//! Copyright (c) systemprompt.io — Business Source License 1.1.
10//! See <https://systemprompt.io> for licensing details.
11
12pub(crate) use systemprompt_traits::RepositoryError;
13
14pub type DatabaseResult<T> = Result<T, RepositoryError>;
15
16pub(crate) fn is_undefined_table(e: &sqlx::Error) -> bool {
17 e.as_database_error()
18 .and_then(sqlx::error::DatabaseError::code)
19 .is_some_and(|code| code == "42P01")
20}