From 0992071a7f1a36424bcfaf1fbc84541ea041df1a Mon Sep 17 00:00:00 2001 From: hozan23 Date: Thu, 11 Apr 2024 10:19:20 +0200 Subject: add support for tokio & improve net crate api --- jsonrpc/jsonrpc_internal/src/error.rs | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 jsonrpc/jsonrpc_internal/src/error.rs (limited to 'jsonrpc/jsonrpc_internal/src/error.rs') diff --git a/jsonrpc/jsonrpc_internal/src/error.rs b/jsonrpc/jsonrpc_internal/src/error.rs new file mode 100644 index 0000000..7f89729 --- /dev/null +++ b/jsonrpc/jsonrpc_internal/src/error.rs @@ -0,0 +1,40 @@ +use thiserror::Error as ThisError; + +pub type Result = std::result::Result; + +/// Represents karyon's jsonrpc Error. +#[derive(ThisError, Debug)] +pub enum Error { + #[error(transparent)] + IO(#[from] std::io::Error), + + #[error("Call Error: code: {0} msg: {1}")] + CallError(i32, String), + + #[error("RPC Method Error: code: {0} msg: {1}")] + RPCMethodError(i32, &'static str), + + #[error("Invalid Params: {0}")] + InvalidParams(&'static str), + + #[error("Invalid Request: {0}")] + InvalidRequest(&'static str), + + #[error(transparent)] + ParseJSON(#[from] serde_json::Error), + + #[error("Invalid Message Error: {0}")] + InvalidMsg(&'static str), + + #[error("Unsupported protocol: {0}")] + UnsupportedProtocol(String), + + #[error("Unexpected Error: {0}")] + General(&'static str), + + #[error(transparent)] + KaryonCore(#[from] karyon_core::error::Error), + + #[error(transparent)] + KaryonNet(#[from] karyon_net::Error), +} -- cgit v1.2.3