#[non_exhaustive]pub enum Error {
NoNamedArgs,
RawArgCount {
placeholders: usize,
args: usize,
clause: String,
},
TypeMismatch {
expected: &'static str,
found: &'static str,
},
Incomplete(&'static str),
ConflictingClauses {
first: &'static str,
second: &'static str,
},
Other(String),
}Expand description
Everything that can go wrong while building a query.
Building is pure string work, so the set is small: almost every failure is either “this dialect cannot express that” or “the caller wired the pieces up inconsistently”. Execution errors live in the backend crates.
Rendering itself is infallible — Expression::write_sql
returns nothing. The rare failure is recorded on the
SqlWriter and surfaced once, by
build.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
NoNamedArgs
The dialect has no syntax for named argument placeholders.
bob models this by having a separate DialectWithNamed interface and
type-asserting on it; we keep one trait whose default
write_named_arg records this instead.
RawArgCount
A raw clause’s ? placeholders and its argument list disagree.
The message is byte-compatible with bob’s rawError so a ported test can
compare it directly.
Fields
TypeMismatch
A Value could not be read as the requested Rust type.
Fields
Incomplete(&'static str)
A query is missing a clause it cannot be rendered without.
ConflictingClauses
Two clauses were both set that are alternative spellings of one grammar
production — LIMIT and FETCH — so no statement can carry both.
Deliberately not last-write-wins: the order mods are applied must never
change what a query means (see the modifier-ordering entry in
docs/sql-rendering.md), so the collision is reported instead of
resolved.
Fields
Other(String)
A dialect-specific or generated-code failure that has no shared shape.
Implementations§
Source§impl Error
impl Error
Sourcepub fn type_mismatch(expected: &'static str, found: &'static str) -> Error
pub fn type_mismatch(expected: &'static str, found: &'static str) -> Error
Shorthand for Error::TypeMismatch.
Sourcepub fn raw_arg_count(
placeholders: usize,
args: usize,
clause: impl Into<String>,
) -> Error
pub fn raw_arg_count( placeholders: usize, args: usize, clause: impl Into<String>, ) -> Error
Shorthand for Error::RawArgCount.
Sourcepub fn conflicting_clauses(first: &'static str, second: &'static str) -> Error
pub fn conflicting_clauses(first: &'static str, second: &'static str) -> Error
Shorthand for Error::ConflictingClauses.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()