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");
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());
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");
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());
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
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
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());
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());
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");
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");
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");
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");
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");
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");
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");
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
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
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");
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");
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");
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");
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");
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");
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");
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
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");
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");
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");
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");
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");
Implementations§
Source§impl ClientError
impl ClientError
Sourcepub fn registration_failed(reason: impl Into<String>) -> Self
pub fn registration_failed(reason: impl Into<String>) -> Self
Create a registration failed error
Sourcepub fn authentication_failed(reason: impl Into<String>) -> Self
pub fn authentication_failed(reason: impl Into<String>) -> Self
Create an authentication failed error
Sourcepub fn call_setup_failed(reason: impl Into<String>) -> Self
pub fn call_setup_failed(reason: impl Into<String>) -> Self
Create a call setup failed error
Sourcepub fn media_negotiation_failed(reason: impl Into<String>) -> Self
pub fn media_negotiation_failed(reason: impl Into<String>) -> Self
Create a media negotiation failed error
Sourcepub fn network_error(reason: impl Into<String>) -> Self
pub fn network_error(reason: impl Into<String>) -> Self
Create a network error
Sourcepub fn protocol_error(reason: impl Into<String>) -> Self
pub fn protocol_error(reason: impl Into<String>) -> Self
Create a protocol error
Sourcepub fn internal_error(reason: impl Into<String>) -> Self
pub fn internal_error(reason: impl Into<String>) -> Self
Create an internal error
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if this error is recoverable
Sourcepub fn is_auth_error(&self) -> bool
pub fn is_auth_error(&self) -> bool
Check if error indicates authentication issue
Sourcepub fn is_call_error(&self) -> bool
pub fn is_call_error(&self) -> bool
Check if error is call-related
Trait Implementations§
Source§impl Clone for ClientError
impl Clone for ClientError
Source§fn clone(&self) -> ClientError
fn clone(&self) -> ClientError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more