pub struct ExtensionError { /* private fields */ }Expand description
An error that can occur during DuckDB extension initialization or registration.
This type is designed for use with the ? operator inside the extension
entry point. It can be reported back to DuckDB via access.set_error.
§Construction
use quack_rs::error::ExtensionError;
// From a string literal
let e = ExtensionError::from("something went wrong");
// From a String
let msg = format!("failed: {}", 42);
let e = ExtensionError::from(msg);
// Wrapping another error
let parse_err: Result<i32, _> = "not a number".parse();
let e = parse_err.map_err(ExtensionError::from_error);Implementations§
Source§impl ExtensionError
impl ExtensionError
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
Creates a new ExtensionError with the given message.
§Example
use quack_rs::error::ExtensionError;
let err = ExtensionError::new("registration failed");
assert_eq!(err.to_string(), "registration failed");Sourcepub fn from_error<E: Error>(e: E) -> Self
pub fn from_error<E: Error>(e: E) -> Self
Wraps any std::error::Error into an ExtensionError.
§Example
use quack_rs::error::ExtensionError;
let result: Result<i32, _> = "abc".parse::<i32>();
let err = result.map_err(ExtensionError::from_error);
assert!(err.is_err());Sourcepub fn to_c_string(&self) -> CString
pub fn to_c_string(&self) -> CString
Converts this error into a CString suitable for passing to set_error.
If the message contains a null byte (which is valid in a Rust String but
not in a C string), the message is truncated at the first null byte.
§Example
use quack_rs::error::ExtensionError;
let err = ExtensionError::new("oops");
let cstr = err.to_c_string();
assert_eq!(cstr.to_str().unwrap(), "oops");Trait Implementations§
Source§impl Clone for ExtensionError
impl Clone for ExtensionError
Source§fn clone(&self) -> ExtensionError
fn clone(&self) -> ExtensionError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ExtensionError
impl Debug for ExtensionError
Source§impl Display for ExtensionError
impl Display for ExtensionError
Source§impl Error for ExtensionError
impl Error for ExtensionError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<&str> for ExtensionError
impl From<&str> for ExtensionError
Source§impl From<String> for ExtensionError
impl From<String> for ExtensionError
Source§impl PartialEq for ExtensionError
impl PartialEq for ExtensionError
impl Eq for ExtensionError
impl StructuralPartialEq for ExtensionError
Auto Trait Implementations§
impl Freeze for ExtensionError
impl RefUnwindSafe for ExtensionError
impl Send for ExtensionError
impl Sync for ExtensionError
impl Unpin for ExtensionError
impl UnsafeUnpin for ExtensionError
impl UnwindSafe for ExtensionError
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
Mutably borrows from an owned value. Read more