Struct Error

pub struct Error {
    pub kind: ErrorKind,
    pub location: &'static Location<'static>,
}
Expand description

Error type used extnesively by this crate.

It can represent two types of errors, “critical” and “soft” errors. With “critical” errors Kanzi is left in undefined state and the exectuion might trigger unexpected behavior; while “soft” errors are produced by this library without calling into Kanzi, so those might be handled and the execution can continue.

All errors are adorned with Location. This gives limited context, which might be helpful during debugging.

Fields§

§kind: ErrorKind§location: &'static Location<'static>

Implementations§

§

impl Error

pub fn critical_error(context: &str) -> Error

Critical exception from Kanzi. Getting this implies that Kanzi is left in inconsistent state and further usage of API might not be safe.

let error = Error::critical_error("Failed to locate '#DATA: Node2D' in a screen tree");
assert_eq!(
    error.to_string(),
    r#"
CriticalError (Unknown): Failed to locate '#DATA: Node2D' in a screen tree
  at 'crates\kzbridge\src\exceptions.rs':7:13
    "#.trim(),
);

pub const fn stale_object() -> Error

pub const fn invalid_argument() -> Error

pub const fn object_not_found() -> Error

pub const fn index_out_of_bounds() -> Error

pub const fn is_critical_error(&self) -> bool

pub const fn is_soft_error(&self) -> bool

Execution can safely continue when soft error (any error except for Self::CriticalError) is returned.

pub const fn is_stale_object(&self) -> bool

pub const fn is_invalid_argument(&self) -> bool

pub const fn is_object_not_found(&self) -> bool

pub const fn is_index_out_of_bounds(&self) -> bool

pub const fn is_type_mismatch(&self) -> bool

pub const fn as_sys_kind(&self) -> ExecutionStatusKind

pub fn get_last_error() -> Option<Error>

Trait Implementations§

§

impl Clone for Error

§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Error

§

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

Formats the value using the given formatter. Read more
§

impl Display for Error

§

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

let error = Error::critical_error("Couldn't find provided URL");
assert_eq!(
    error.to_string(),
    r#"
CriticalError (Unknown): Couldn't find provided URL
  at 'crates\kzbridge\src\exceptions.rs':7:13
    "#.trim(),
);
§

impl Error for Error

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

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnwindSafe for Error

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
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.