1use std::fmt;
2
3pub type RpcResult<T> = Result<T, RpcError>;
4
5#[derive(Debug)]
6pub enum RpcError {
7 ServiceError(String),
8 InvalidRequest(String),
9 InternalError(String),
10}
11
12impl fmt::Display for RpcError {
13 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14 match self {
15 RpcError::ServiceError(msg) => write!(f, "Service error: {}", msg),
16 RpcError::InvalidRequest(msg) => write!(f, "Invalid request: {}", msg),
17 RpcError::InternalError(msg) => write!(f, "Internal error: {}", msg),
18 }
19 }
20}
21
22impl std::error::Error for RpcError {}
23
24impl From<pipeline_service::ServiceError> for RpcError {
25 fn from(err: pipeline_service::ServiceError) -> Self {
26 RpcError::ServiceError(err.to_string())
27 }
28}