pub struct DataFusionErrorBuilder(/* private fields */);
Expand description
A builder for DataFusionError
This builder can be used to collect multiple errors and return them as a
DataFusionError::Collection
.
§Example: no errors
let mut builder = DataFusionError::builder();
// ok_or returns the value if no errors have been added
assert_eq!(builder.error_or(42).unwrap(), 42);
§Example: with errors
let mut builder = DataFusionError::builder();
builder.add_error(DataFusionError::Internal("foo".to_owned()));
// ok_or returns the value if no errors have been added
assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
Implementations§
Source§impl DataFusionErrorBuilder
impl DataFusionErrorBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new DataFusionErrorBuilder
Sourcepub fn add_error(&mut self, error: DataFusionError)
pub fn add_error(&mut self, error: DataFusionError)
Add an error to the in progress list
§Example
let mut builder = DataFusionError::builder();
builder.add_error(DataFusionError::Internal("foo".to_owned()));
assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
Sourcepub fn with_error(self, error: DataFusionError) -> Self
pub fn with_error(self, error: DataFusionError) -> Self
Add an error to the in progress list, returning the builder
§Example
let builder = DataFusionError::builder()
.with_error(DataFusionError::Internal("foo".to_owned()));
assert_contains!(builder.error_or(42).unwrap_err().to_string(), "Internal error: foo");
Sourcepub fn error_or<T>(self, ok: T) -> Result<T, DataFusionError>
pub fn error_or<T>(self, ok: T) -> Result<T, DataFusionError>
Returns Ok(ok)
if no errors were added to the builder,
otherwise returns a Result::Err
Trait Implementations§
Source§impl Debug for DataFusionErrorBuilder
impl Debug for DataFusionErrorBuilder
Source§impl Default for DataFusionErrorBuilder
impl Default for DataFusionErrorBuilder
Source§fn default() -> DataFusionErrorBuilder
fn default() -> DataFusionErrorBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DataFusionErrorBuilder
impl !RefUnwindSafe for DataFusionErrorBuilder
impl Send for DataFusionErrorBuilder
impl Sync for DataFusionErrorBuilder
impl Unpin for DataFusionErrorBuilder
impl !UnwindSafe for DataFusionErrorBuilder
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
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>
Converts
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>
Converts
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