Skip to main content

ErrorData

Struct ErrorData 

Source
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

Source

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.

Source

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.

Source

pub const fn as_raw(&self) -> duckdb_error_data

Returns the raw handle without consuming the ErrorData.

Source

pub const fn is_null(&self) -> bool

Returns true if the underlying handle is null.

Source

pub fn has_error(&self) -> bool

Returns true if this handle represents an actual error.

Source

pub fn error_type(&self) -> DuckDbErrorType

Returns the error category.

Source

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.

Source

pub fn into_extension_error(self) -> ExtensionError

Consumes the ErrorData and converts it into an ExtensionError.

Useful for propagating a structured DuckDB error through ?.

Source

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 Debug for ErrorData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ErrorData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for ErrorData

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Error for ErrorData

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ErrorData> for ExtensionError

Source§

fn from(err: ErrorData) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.