Enum ClientError

Source
pub enum ClientError {
Show 34 variants RegistrationFailed { reason: String, }, NotRegistered, RegistrationExpired, AuthenticationFailed { reason: String, }, CallNotFound { call_id: Uuid, }, CallAlreadyExists { call_id: Uuid, }, InvalidCallState { call_id: Uuid, current_state: CallState, }, InvalidCallStateGeneric { expected: String, actual: String, }, CallSetupFailed { reason: String, }, CallTerminated { reason: String, }, MediaNegotiationFailed { reason: String, }, MediaError { details: String, }, NoCompatibleCodecs, AudioDeviceError { reason: String, }, NetworkError { reason: String, }, ConnectionTimeout, ServerUnreachable { server: String, }, ProtocolError { reason: String, }, InvalidSipMessage { reason: String, }, ProtocolVersionMismatch { expected: String, actual: String, }, InvalidConfiguration { field: String, reason: String, }, MissingConfiguration { field: String, }, TransportFailed { reason: String, }, TransportNotAvailable { transport_type: String, }, SessionManagerError { reason: String, }, TooManySessions { limit: usize, }, InternalError { message: String, }, OperationTimeout { duration_ms: u64, }, NotImplemented { feature: String, reason: String, }, PermissionDenied { operation: String, }, ResourceUnavailable { resource: String, }, UnsupportedCodec { codec: String, }, CodecError { reason: String, }, ExternalServiceError { service: String, reason: String, },
}
Expand description

Comprehensive error types for SIP client operations

This enum covers all possible error conditions that can occur during VoIP client operations, organized by functional area for easy handling.

§Error Categories

  • Registration Errors - SIP server registration and authentication issues
  • Call Errors - Call lifecycle and state management issues
  • Media Errors - Audio, codecs, and RTP stream issues
  • Network Errors - Connectivity and transport problems
  • Protocol Errors - SIP protocol violations and parsing issues
  • Configuration Errors - Invalid settings and missing parameters
  • System Errors - Internal failures and resource limitations

§Examples

use rvoip_client_core::ClientError;
 
// Check error categories for appropriate handling
let error = ClientError::registration_failed("Invalid credentials");
assert_eq!(error.category(), "registration");
 
// Check authentication errors
let auth_error = ClientError::authentication_failed("Invalid password");
assert!(auth_error.is_auth_error());
 
// Create specific error types
let timeout_error = ClientError::OperationTimeout { duration_ms: 5000 };
assert!(timeout_error.is_recoverable());

Variants§

§

RegistrationFailed

Registration related errors Registration attempt failed due to server or authentication issues

This error occurs when the SIP REGISTER request is rejected by the server, typically due to authentication failures, server errors, or network issues.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::RegistrationFailed {
    reason: "401 Unauthorized - Invalid credentials".to_string()
};
 
assert_eq!(error.category(), "registration");

Fields

§reason: String

Detailed reason for the registration failure

§

NotRegistered

Client is not currently registered with any SIP server

This error occurs when attempting operations that require an active registration (like making calls) when no registration is active.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::NotRegistered;
assert!(error.is_auth_error());
§

RegistrationExpired

SIP registration has expired and needs to be renewed

This error occurs when the registration lifetime has elapsed and the server no longer considers this client registered.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::RegistrationExpired;
assert!(error.is_auth_error());
assert_eq!(error.category(), "registration");
§

AuthenticationFailed

SIP digest authentication failed

This error occurs when the server rejects the authentication credentials provided during registration or call setup.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::AuthenticationFailed {
    reason: "Wrong password for user alice".to_string()
};
 
assert!(error.is_auth_error());

Fields

§reason: String

Specific reason for authentication failure

§

CallNotFound

Call related errors Attempted to operate on a call that doesn’t exist

This error occurs when referencing a call ID that is not found in the client’s active call list.

§Examples

use rvoip_client_core::ClientError;
use uuid::Uuid;
 
let call_id = Uuid::new_v4();
let error = ClientError::CallNotFound { call_id };
 
assert!(error.is_call_error());
assert_eq!(error.category(), "call");

Fields

§call_id: Uuid

The call ID that was not found

§

CallAlreadyExists

Attempted to create a call with an ID that already exists

This error occurs when trying to create a new call with a call ID that is already in use by another active call.

§Examples

use rvoip_client_core::ClientError;
use uuid::Uuid;
 
let call_id = Uuid::new_v4();
let error = ClientError::CallAlreadyExists { call_id };
 
assert!(error.is_call_error());

Fields

§call_id: Uuid

The call ID that already exists

§

InvalidCallState

Operation is not valid for the current call state

This error occurs when attempting an operation that is not allowed in the call’s current state (e.g., trying to answer an already connected call).

§Examples

use rvoip_client_core::ClientError;
use rvoip_client_core::call::CallState;
use uuid::Uuid;
 
let call_id = Uuid::new_v4();
let error = ClientError::InvalidCallState {
    call_id,
    current_state: CallState::Terminated
};
 
assert!(error.is_call_error());

Fields

§call_id: Uuid

The call ID that has an invalid state

§current_state: CallState

The current state that prevents the operation

§

InvalidCallStateGeneric

Generic call state validation error with string descriptions

This error provides a more flexible way to report call state issues when the specific CallState enum values are not available.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::InvalidCallStateGeneric {
    expected: "Connected".to_string(),
    actual: "Terminated".to_string()
};
 
assert!(error.is_call_error());

Fields

§expected: String

The expected call state for the operation

§actual: String

The actual call state that was encountered

§

CallSetupFailed

Call establishment or setup failed

This error occurs during the call setup phase when the INVITE request fails due to network, server, or remote party issues.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::CallSetupFailed {
    reason: "486 Busy Here".to_string()
};
 
assert!(error.is_call_error());

Fields

§reason: String

Specific reason for call setup failure

§

CallTerminated

Call was terminated unexpectedly

This error occurs when a call ends due to network issues, remote party disconnect, or other unexpected conditions.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::CallTerminated {
    reason: "Network connection lost".to_string()
};
 
assert!(error.is_call_error());

Fields

§reason: String

Reason for call termination

§

MediaNegotiationFailed

Media related errors SDP negotiation or media setup failed

This error occurs when the client cannot establish media streams due to codec mismatches, network issues, or SDP parsing problems.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::MediaNegotiationFailed {
    reason: "No common codecs found".to_string()
};
 
assert_eq!(error.category(), "media");

Fields

§reason: String

Specific reason for media negotiation failure

§

MediaError

General media processing error

This error covers various media-related issues including RTP processing problems, audio device failures, and codec errors.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::MediaError {
    details: "RTP packet processing failed".to_string()
};
 
assert_eq!(error.category(), "media");

Fields

§details: String

Detailed description of the media error

§

NoCompatibleCodecs

No audio codecs are compatible between endpoints

This error occurs when the local and remote endpoints cannot agree on a common audio codec for the call.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::NoCompatibleCodecs;
assert_eq!(error.category(), "media");
§

AudioDeviceError

Audio device (microphone/speaker) error

This error occurs when there are problems accessing or using the system’s audio input/output devices.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::AudioDeviceError {
    reason: "Microphone permission denied".to_string()
};
 
assert_eq!(error.category(), "media");

Fields

§reason: String

Specific reason for audio device failure

§

NetworkError

Network and transport errors General network connectivity or communication error

This error occurs for various network-related issues including DNS resolution failures, socket errors, and packet loss.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::NetworkError {
    reason: "DNS resolution failed for server.example.com".to_string()
};
 
assert!(error.is_recoverable());
assert_eq!(error.category(), "network");

Fields

§reason: String

Specific description of the network error

§

ConnectionTimeout

Operation timed out waiting for network response

This error occurs when network operations (like SIP requests) do not receive a response within the configured timeout period.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ConnectionTimeout;
assert!(error.is_recoverable());
assert_eq!(error.category(), "network");
§

ServerUnreachable

Cannot reach the specified SIP server

This error occurs when the client cannot establish a connection to the SIP server due to network issues or incorrect server address.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ServerUnreachable {
    server: "sip.example.com:5060".to_string()
};
 
assert_eq!(error.category(), "network");

Fields

§server: String

The server address that could not be reached

§

ProtocolError

Protocol errors SIP protocol violation or parsing error

This error occurs when receiving malformed SIP messages or encountering protocol violations that prevent proper communication.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ProtocolError {
    reason: "Invalid SIP URI format".to_string()
};
 
assert_eq!(error.category(), "protocol");

Fields

§reason: String

Specific description of the protocol error

§

InvalidSipMessage

Received an invalid or malformed SIP message

This error occurs when parsing SIP messages that do not conform to the SIP specification or contain invalid syntax.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::InvalidSipMessage {
    reason: "Missing required Via header".to_string()
};
 
assert_eq!(error.category(), "protocol");

Fields

§reason: String

Specific reason why the SIP message is invalid

§

ProtocolVersionMismatch

SIP protocol version mismatch

This error occurs when the client and server are using incompatible versions of the SIP protocol.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ProtocolVersionMismatch {
    expected: "SIP/2.0".to_string(),
    actual: "SIP/3.0".to_string()
};
 
assert_eq!(error.category(), "protocol");

Fields

§expected: String

The expected protocol version

§actual: String

The actual protocol version received

§

InvalidConfiguration

Configuration errors Client configuration is invalid

This error occurs when the client is configured with invalid settings that prevent proper operation.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::InvalidConfiguration {
    field: "sip_port".to_string(),
    reason: "Port must be between 1024 and 65535".to_string()
};
 
assert_eq!(error.category(), "configuration");

Fields

§field: String

The configuration field that is invalid

§reason: String

Explanation of why the configuration is invalid

§

MissingConfiguration

Required configuration parameter is missing

This error occurs when mandatory configuration values are not provided to the client.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::MissingConfiguration {
    field: "server_address".to_string()
};
 
assert_eq!(error.category(), "configuration");

Fields

§field: String

The configuration field that is missing

§

TransportFailed

Transport errors Network transport layer failure

This error occurs when the underlying transport (UDP/TCP/TLS) encounters failures that prevent SIP communication.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::TransportFailed {
    reason: "TLS handshake failed".to_string()
};
 
assert!(error.is_recoverable());
assert_eq!(error.category(), "network");

Fields

§reason: String

Specific reason for transport failure

§

TransportNotAvailable

Requested transport type is not available

This error occurs when trying to use a transport protocol that is not supported or configured in the client.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::TransportNotAvailable {
    transport_type: "WSS".to_string()
};
 
assert_eq!(error.category(), "network");

Fields

§transport_type: String

The transport type that is not available

§

SessionManagerError

Session management errors Session manager internal error

This error occurs when the session management layer encounters internal failures that prevent proper session handling.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::SessionManagerError {
    reason: "Session state corruption detected".to_string()
};
 
assert_eq!(error.category(), "session");

Fields

§reason: String

Specific reason for session manager failure

§

TooManySessions

Maximum number of concurrent sessions exceeded

This error occurs when attempting to create more sessions than the configured or system-imposed limit allows.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::TooManySessions {
    limit: 10
};
 
assert_eq!(error.category(), "session");

Fields

§limit: usize

The maximum number of sessions allowed

§

InternalError

Generic errors Internal client error

This error indicates an unexpected internal failure within the client library that should not normally occur.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::InternalError {
    message: "Unexpected null pointer in call handler".to_string()
};
 
assert_eq!(error.category(), "system");

Fields

§message: String

Description of the internal error

§

OperationTimeout

Operation exceeded its timeout deadline

This error occurs when an operation takes longer than its configured timeout period to complete.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::OperationTimeout {
    duration_ms: 5000
};
 
assert_eq!(error.category(), "system");

Fields

§duration_ms: u64

The timeout duration in milliseconds

§

NotImplemented

Requested feature is not yet implemented

This error occurs when attempting to use functionality that is planned but not yet available in the current version.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::NotImplemented {
    feature: "Video calls".to_string(),
    reason: "Planned for version 2.0".to_string()
};
 
assert_eq!(error.category(), "system");

Fields

§feature: String

The feature that is not implemented

§reason: String

Explanation of implementation status

§

PermissionDenied

Operation not permitted in current context

This error occurs when the user or system lacks the necessary permissions to perform the requested operation.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::PermissionDenied {
    operation: "Access microphone".to_string()
};
 
assert_eq!(error.category(), "system");

Fields

§operation: String

The operation that was denied

§

ResourceUnavailable

Required resource is not available

This error occurs when the system cannot allocate or access a required resource (memory, ports, devices, etc.).

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ResourceUnavailable {
    resource: "RTP port range 10000-20000".to_string()
};
 
assert_eq!(error.category(), "system");

Fields

§resource: String

The resource that is unavailable

§

UnsupportedCodec

Codec and media format errors Audio codec is not supported

This error occurs when attempting to use an audio codec that is not available in the current client configuration.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::UnsupportedCodec {
    codec: "G.729".to_string()
};
 
assert_eq!(error.category(), "media");

Fields

§codec: String

The codec that is not supported

§

CodecError

Codec processing error

This error occurs when there are problems encoding or decoding audio using the selected codec.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::CodecError {
    reason: "OPUS encoder initialization failed".to_string()
};
 
assert_eq!(error.category(), "media");

Fields

§reason: String

Specific reason for codec error

§

ExternalServiceError

External service errors External service or dependency failure

This error occurs when an external service (STUN server, media relay, authentication service, etc.) fails or becomes unavailable.

§Examples

use rvoip_client_core::ClientError;
 
let error = ClientError::ExternalServiceError {
    service: "STUN server".to_string(),
    reason: "stun.example.com connection refused".to_string()
};
 
assert_eq!(error.category(), "system");

Fields

§service: String

The external service that failed

§reason: String

Specific reason for the service failure

Implementations§

Source§

impl ClientError

Source

pub fn registration_failed(reason: impl Into<String>) -> Self

Create a registration failed error

Source

pub fn authentication_failed(reason: impl Into<String>) -> Self

Create an authentication failed error

Source

pub fn call_setup_failed(reason: impl Into<String>) -> Self

Create a call setup failed error

Source

pub fn media_negotiation_failed(reason: impl Into<String>) -> Self

Create a media negotiation failed error

Source

pub fn network_error(reason: impl Into<String>) -> Self

Create a network error

Source

pub fn protocol_error(reason: impl Into<String>) -> Self

Create a protocol error

Source

pub fn internal_error(reason: impl Into<String>) -> Self

Create an internal error

Source

pub fn is_recoverable(&self) -> bool

Check if this error is recoverable

Source

pub fn is_auth_error(&self) -> bool

Check if error indicates authentication issue

Source

pub fn is_call_error(&self) -> bool

Check if error is call-related

Source

pub fn category(&self) -> &'static str

Get error category for metrics/logging

Trait Implementations§

Source§

impl Clone for ClientError

Source§

fn clone(&self) -> ClientError

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 ClientError

Source§

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

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

impl Display for ClientError

Source§

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

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

impl Error for ClientError

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§

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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