pub struct ErrorData { /* private fields */ }Expand description
RAII wrapper for a duckdb_error_data handle.
Automatically destroyed when dropped. Carries a structured error category
(DuckDbErrorType) and a human-readable message.
Implements Display and std::error::Error, and
converts into ExtensionError via From (or
into_extension_error) so it can be
propagated with ?.
Implementations§
Source§impl ErrorData
impl ErrorData
Sourcepub fn new(error_type: DuckDbErrorType, message: &str) -> Self
pub fn new(error_type: DuckDbErrorType, message: &str) -> Self
Creates a new structured error with the given category and message.
If message contains an interior null byte it is truncated at that point.
Sourcepub const unsafe fn from_raw(raw: duckdb_error_data) -> Self
pub const unsafe fn from_raw(raw: duckdb_error_data) -> Self
Wraps a raw duckdb_error_data handle, taking ownership.
§Safety
raw must be a duckdb_error_data returned by a DuckDB API call (it may
be null). The caller must not destroy the handle after this call.
Sourcepub const fn as_raw(&self) -> duckdb_error_data
pub const fn as_raw(&self) -> duckdb_error_data
Returns the raw handle without consuming the ErrorData.
Sourcepub fn error_type(&self) -> DuckDbErrorType
pub fn error_type(&self) -> DuckDbErrorType
Returns the error category.
Sourcepub fn message(&self) -> Option<String>
pub fn message(&self) -> Option<String>
Returns the error message, or None if the handle is null or the message
is not valid UTF-8.
The returned string is owned by DuckDB and copied into a Rust String.
Sourcepub fn into_extension_error(self) -> ExtensionError
pub fn into_extension_error(self) -> ExtensionError
Consumes the ErrorData and converts it into an ExtensionError.
Useful for propagating a structured DuckDB error through ?.
Sourcepub const fn into_raw(self) -> duckdb_error_data
pub const fn into_raw(self) -> duckdb_error_data
Consumes the ErrorData and returns the raw handle.
The caller takes ownership and must call duckdb_destroy_error_data.
Trait Implementations§
Source§impl Error for ErrorData
impl Error for ErrorData
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()