Skip to main content

NanoRosError

Struct NanoRosError 

Source
pub struct NanoRosError { /* private fields */ }
Expand description

Main error type for nros operations

This error type provides comprehensive coverage of all failure modes in nros, with optional context information (topic name, service name, etc.) when available.

§Error Categories

  • Serialization: CDR encoding/decoding failures
  • Transport: Network and communication failures
  • Node/Context: Node creation and management failures
  • Publisher/Subscriber: Pub/sub failures
  • Service/Client: Service call failures
  • Action: Action server/client failures
  • Timer: Timer management failures
  • Parameter: Parameter declaration/access failures

§Example

use nros_core::NanoRosError;

let err = NanoRosError::timeout();
assert!(err.is_timeout());
assert!(!err.is_take_failed());

// Errors with context
let err = NanoRosError::topic_name_invalid("/invalid topic!");
assert!(err.context().is_some());

Implementations§

Source§

impl NanoRosError

Source

pub const fn new(code: RclReturnCode) -> Self

Create a new error with the given code

Source

pub const fn with_context(code: RclReturnCode, context: ErrorContext) -> Self

Create a new error with context

Source

pub const fn timeout() -> Self

Create a timeout error

Source

pub const fn invalid_argument() -> Self

Create an invalid argument error

Source

pub const fn unsupported() -> Self

Create an unsupported operation error

Source

pub const fn bad_alloc() -> Self

Create an allocation failure error

Source

pub const fn error() -> Self

Create a generic error

Source

pub const fn node_invalid() -> Self

Create an invalid node error

Source

pub const fn node_invalid_name(name: &'static str) -> Self

Create an invalid node name error with context

Source

pub const fn node_invalid_namespace(namespace: &'static str) -> Self

Create an invalid node namespace error with context

Source

pub const fn topic_name_invalid(topic: &'static str) -> Self

Create an invalid topic name error with context

Source

pub const fn publisher_invalid() -> Self

Create a publisher invalid error

Source

pub const fn subscription_invalid() -> Self

Create a subscription invalid error

Source

pub const fn subscription_take_failed() -> Self

Create a subscription take failed error

Source

pub const fn service_name_invalid(service: &'static str) -> Self

Create an invalid service name error with context

Source

pub const fn service_invalid() -> Self

Create a service invalid error

Source

pub const fn service_take_failed() -> Self

Create a service take failed error

Source

pub const fn client_invalid() -> Self

Create a client invalid error

Source

pub const fn client_take_failed() -> Self

Create a client take failed error

Source

pub const fn timer_invalid() -> Self

Create a timer invalid error

Source

pub const fn timer_canceled() -> Self

Create a timer canceled error

Source

pub const fn action_goal_rejected() -> Self

Create an action goal rejected error

Source

pub const fn action_client_invalid() -> Self

Create an action client invalid error

Source

pub const fn action_server_invalid() -> Self

Create an action server invalid error

Source

pub const fn action_goal_handle_invalid() -> Self

Create an action goal handle invalid error

Source

pub const fn already_init() -> Self

Create an already initialized error

Source

pub const fn not_init() -> Self

Create a not initialized error

Source

pub const fn already_shutdown() -> Self

Create an already shutdown error

Source

pub fn serialization(err: SerError) -> Self

Create a serialization error

Source

pub fn deserialization(err: DeserError) -> Self

Create a deserialization error

Source

pub const fn code(&self) -> RclReturnCode

Returns the error code

Source

pub const fn context(&self) -> Option<&ErrorContext>

Returns the error context, if any

Source

pub const fn nested(&self) -> Option<&NestedError>

Returns the nested error, if any

Source

pub const fn is_timeout(&self) -> bool

Returns true if this error was due to a timeout

Source

pub const fn is_take_failed(&self) -> bool

Returns true if this error was because a take operation failed (subscription, service, client, or action take failed)

Source

pub const fn is_action_error(&self) -> bool

Returns true if this is an action-related error

Source

pub const fn is_serialization_error(&self) -> bool

Returns true if this is a serialization or deserialization error

Trait Implementations§

Source§

impl Clone for NanoRosError

Source§

fn clone(&self) -> NanoRosError

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

impl Debug for NanoRosError

Source§

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

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

impl Display for NanoRosError

Source§

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

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

impl Error for NanoRosError

Available on crate feature std only.
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<DeserError> for NanoRosError

Source§

fn from(e: DeserError) -> Self

Converts to this type from the input type.
Source§

impl From<RclReturnCode> for NanoRosError

Source§

fn from(code: RclReturnCode) -> Self

Converts to this type from the input type.
Source§

impl From<SerError> for NanoRosError

Source§

fn from(e: SerError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for NanoRosError

Source§

fn eq(&self, other: &NanoRosError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for NanoRosError

Source§

impl StructuralPartialEq for NanoRosError

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

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.