Initial implementation: relay server + common protocol + client stub
This commit is contained in:
commit
7285a33cff
17 changed files with 926 additions and 0 deletions
35
crates/common/src/error.rs
Normal file
35
crates/common/src/error.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum HeliosError {
|
||||
/// WebSocket protocol error
|
||||
Protocol(String),
|
||||
/// JSON serialization/deserialization error
|
||||
Serialization(String),
|
||||
/// Session not found
|
||||
SessionNotFound(String),
|
||||
/// Request timed out waiting for client response
|
||||
Timeout(String),
|
||||
/// Generic internal error
|
||||
Internal(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for HeliosError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
HeliosError::Protocol(msg) => write!(f, "Protocol error: {msg}"),
|
||||
HeliosError::Serialization(msg) => write!(f, "Serialization error: {msg}"),
|
||||
HeliosError::SessionNotFound(id) => write!(f, "Session not found: {id}"),
|
||||
HeliosError::Timeout(msg) => write!(f, "Request timed out: {msg}"),
|
||||
HeliosError::Internal(msg) => write!(f, "Internal error: {msg}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for HeliosError {}
|
||||
|
||||
impl From<serde_json::Error> for HeliosError {
|
||||
fn from(e: serde_json::Error) -> Self {
|
||||
HeliosError::Serialization(e.to_string())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue