Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { NoLicense, UnknownLicenseType { bits: i32, }, RecursionLimit { path: String, limit: usize, }, Engine { code: i32, dispid: i32, }, Com { hresult: i32, dispid: i32, }, UnexpectedType { expected: &'static str, actual: &'static str, }, }
Expand description

An error from a TestStand™ COM operation.

Every fallible member of the public API returns Result<_, Error> (i.e. rs_teststand::Error). Library code never panics; failures always arrive here.

Engine failures are reported by name where the engine defines one, so a caller is not left decoding a bare number:

use rs_teststand::Error;

// `dispid` names the member that failed; 0 means the failure came from
// outside a member call.
let out_of_memory = Error::Engine { code: -17000, dispid: 0 };
assert_eq!(out_of_memory.code_name(), Some("TS_Err_OutOfMemory"));
assert!(out_of_memory.to_string().contains("TS_Err_OutOfMemory"));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

NoLicense

The station holds no license.

Raised by Engine::require_license, not by the engine, so that “unlicensed” is reported once and up front rather than as whatever operation later happened to need a license.

§

UnknownLicenseType

The engine named a license value this build does not know.

A newer engine may define one this crate predates. The number is carried through rather than mapped onto a near neighbour.

Fields

§bits: i32

The value the engine reported.

§

RecursionLimit

A property tree was walked deeper than the caller allowed.

Usually a cycle rather than genuine depth. A live SequenceContext lists ThisContext among its own sub-properties, so it contains itself, and a walk with no limit recurses until the stack is gone. path is where the limit was reached, which is normally enough to see the loop.

Fields

§path: String

The lookup path at which the limit was hit.

§limit: usize

The limit that was exceeded.

§

Engine

The engine raised a failure it has a name for.

code is the engine’s own error code, taken from the raised exception rather than the generic COM DISP_E_EXCEPTION wrapper.

Fields

§code: i32

The engine error code.

§dispid: i32

The dispatch id of the member that failed, or 0 when the failure did not come from a member call.

A bare engine code does not say which call refused, which is the first thing worth knowing; this narrows it to one member.

§

Com

A COM call failed with a code the engine does not name, a standard Windows HRESULT, or a code newer than the generated table.

Fields

§hresult: i32

The 32-bit HRESULT.

§dispid: i32

The dispatch id of the member that failed, or 0.

§

UnexpectedType

A returned value was not the type the wrapper expected, an internal mismatch between the wrapper and the live object model.

Fields

§expected: &'static str

The type the wrapper asked for.

§actual: &'static str

The type actually returned.

Implementations§

Source§

impl Error

Source

pub const fn code_name(&self) -> Option<&'static str>

The engine’s name for this error, when it has one.

Returns None for plain Windows HRESULTs and for type mismatches.

Source

pub const fn code(&self) -> Option<i32>

The underlying numeric code, when the failure came from COM.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

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
Source§

impl From<ComError> for Error

Source§

fn from(error: ComError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin 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
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.