From 028940fe3e0a87cdc421a6d07f1ecfb6c208b9d0 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Tue, 21 May 2024 02:20:45 +0200 Subject: jsonrpc: support pubsub --- jsonrpc/src/error.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'jsonrpc/src/error.rs') diff --git a/jsonrpc/src/error.rs b/jsonrpc/src/error.rs index 7f89729..d68e169 100644 --- a/jsonrpc/src/error.rs +++ b/jsonrpc/src/error.rs @@ -11,6 +11,9 @@ pub enum Error { #[error("Call Error: code: {0} msg: {1}")] CallError(i32, String), + #[error("Subscribe Error: code: {0} msg: {1}")] + SubscribeError(i32, String), + #[error("RPC Method Error: code: {0} msg: {1}")] RPCMethodError(i32, &'static str), @@ -29,6 +32,15 @@ pub enum Error { #[error("Unsupported protocol: {0}")] UnsupportedProtocol(String), + #[error("Subscription not found: {0}")] + SubscriptionNotFound(String), + + #[error(transparent)] + ChannelRecv(#[from] async_channel::RecvError), + + #[error("Channel broadcast Error: {0}")] + ChannelBroadcast(String), + #[error("Unexpected Error: {0}")] General(&'static str), @@ -38,3 +50,9 @@ pub enum Error { #[error(transparent)] KaryonNet(#[from] karyon_net::Error), } + +impl From> for Error { + fn from(error: async_channel::SendError) -> Self { + Error::ChannelBroadcast(error.to_string()) + } +} -- cgit v1.2.3