#[non_exhaustive]pub enum QueryError {
UnsupportedConstraint,
InvalidColumnType {
backend: DatabaseBackend,
message: String,
},
SchemaError(String),
BackendError {
backend: DatabaseBackend,
message: String,
},
UnsupportedAction(String),
Other(String),
}Expand description
Errors returned by SQL query generation.
QueryError is #[non_exhaustive], so match arms must include a wildcard.
Matching variants:
use vespertide_query::{QueryError, DatabaseBackend};
fn report(err: &QueryError) -> String {
match err {
QueryError::SchemaError(msg) => format!("schema: {msg}"),
QueryError::InvalidColumnType { backend, message } => {
format!("type error for {backend:?}: {message}")
}
_ => format!("other: {err}"),
}
}
let schema_err = QueryError::SchemaError("missing table user".into());
assert_eq!(report(&schema_err), "schema: missing table user");
let type_err = QueryError::InvalidColumnType {
backend: DatabaseBackend::Postgres,
message: "inet not supported".into(),
};
assert!(report(&type_err).contains("Postgres"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnsupportedConstraint
The SQL backend doesn’t support the requested table constraint variant.
InvalidColumnType
A column’s type cannot be mapped to the target SQL backend.
Constructor with named fields:
use vespertide_query::{QueryError, DatabaseBackend};
let err = QueryError::InvalidColumnType {
backend: DatabaseBackend::MySql,
message: "inet is not supported by MySQL".into(),
};
assert!(err.to_string().contains("MySql"));
assert!(err.to_string().contains("inet is not supported by MySQL"));SchemaError(String)
A schema validation issue surfaced during query generation (e.g., missing referenced table, malformed constraint).
Constructor and Display:
use vespertide_query::QueryError;
let err = QueryError::SchemaError("referenced table 'user' not found".into());
assert_eq!(err.to_string(), "schema error: referenced table 'user' not found");BackendError
Backend-specific SQL generation failed.
UnsupportedAction(String)
The requested MigrationAction variant isn’t yet supported by query generation.
Other(String)
Match a specific variant (InvalidColumnType, SchemaError, BackendError, UnsupportedAction)
Fallback variant for errors that don’t fit a specific category yet. Will be removed in a future major version — prefer specific variants when possible.
Trait Implementations§
Source§impl Clone for QueryError
impl Clone for QueryError
Source§fn clone(&self) -> QueryError
fn clone(&self) -> QueryError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QueryError
impl Debug for QueryError
Source§impl Display for QueryError
impl Display for QueryError
Source§impl Error for QueryError
impl Error for QueryError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for QueryError
impl RefUnwindSafe for QueryError
impl Send for QueryError
impl Sync for QueryError
impl Unpin for QueryError
impl UnsafeUnpin for QueryError
impl UnwindSafe for QueryError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more