Skip to main content

llama_cpp_4/rpc/
error.rs

1//! Error types for RPC functionality
2
3use std::ffi::NulError;
4use thiserror::Error;
5
6/// Errors that can occur in RPC operations
7#[derive(Debug, Error)]
8pub enum RpcError {
9    /// Failed to initialize RPC backend
10    #[error("Failed to initialize RPC backend for endpoint: {endpoint}")]
11    InitializationFailed {
12        /// Endpoint string passed to initialization
13        endpoint: String,
14    },
15
16    /// Invalid endpoint format
17    #[error("Invalid endpoint format: {endpoint}")]
18    InvalidEndpoint {
19        /// Malformed endpoint string
20        endpoint: String,
21    },
22
23    /// Connection failed
24    #[error("Failed to connect to RPC server at {endpoint}: {reason}")]
25    ConnectionFailed {
26        /// Server address
27        endpoint: String,
28        /// Backend error detail
29        reason: String,
30    },
31
32    /// Server error
33    #[error("RPC server error: {message}")]
34    ServerError {
35        /// Error message from the server
36        message: String,
37    },
38
39    /// Memory query failed
40    #[error("Failed to query device memory")]
41    MemoryQueryFailed,
42
43    /// String conversion error
44    #[error("Failed to convert C string: {0}")]
45    StringConversion(#[from] NulError),
46
47    /// UTF-8 conversion error
48    #[error("Invalid UTF-8: {0}")]
49    Utf8Error(#[from] std::str::Utf8Error),
50
51    /// Feature not available
52    #[error("RPC feature not compiled in. Build with --features rpc")]
53    NotAvailable,
54}