diff --git a/src/cli/console.rs b/src/cli/console.rs index ade28b2c4e2393fd760c67f2f25b195793b86f70..6f7e1a3fbb5ac5af5f0892f9fad32fdb45491243 100644 --- a/src/cli/console.rs +++ b/src/cli/console.rs @@ -18,16 +18,16 @@ use super::admin::UnixClientError; #[derive(thiserror::Error, Debug)] pub enum ReplError { - #[error("{0}")] + #[error(transparent)] Client(#[from] ClientError), - #[error("{0}")] + #[error(transparent)] UnixClient(#[from] UnixClientError), - #[error("{0}")] + #[error(transparent)] Io(#[from] io::Error), - #[error("{0}")] + #[error(transparent)] EditorError(#[from] ReadlineError), #[error("{0}")] diff --git a/src/introspection.rs b/src/introspection.rs index 09a51b7990c67a5ef59e502273d91dc6106601a4..aa9c91293e98a0329d3b71efc52304cd7dac176b 100644 --- a/src/introspection.rs +++ b/src/introspection.rs @@ -340,6 +340,7 @@ pub enum IntrospectionError { #[error("incorrect value for field '{field}': {error}")] ConvertToFieldError { field: String, + #[source] error: Box<dyn std::error::Error>, }, @@ -359,7 +360,11 @@ pub enum IntrospectionError { }, #[error("failed converting '{field}' to a msgpack value: {details}")] - ToRmpvValue { field: String, details: Error }, + ToRmpvValue { + field: String, + #[source] + details: Error, + }, } impl IntrospectionError { diff --git a/src/pgproto/error.rs b/src/pgproto/error.rs index eae8773bc7d5b550a5d7d588c9541895b2d08b74..524e7693a825a5bca5675df58195a2391e8eaebe 100644 --- a/src/pgproto/error.rs +++ b/src/pgproto/error.rs @@ -31,7 +31,7 @@ impl PgErrorCode { // Use case: server could not encode a value into client's format. // To the client it's as meaningful & informative as any other "internal error". #[derive(Error, Debug)] -#[error("{0}")] +#[error(transparent)] pub struct EncodingError(Box<dyn std::error::Error + Send + Sync>); impl EncodingError { @@ -46,7 +46,7 @@ impl IntoBoxError for EncodingError {} // Use case: server could not decode a value received from client. // To the client it's as meaningful & informative as any other "internal error". #[derive(Error, Debug)] -#[error("{0}")] +#[error(transparent)] pub struct DecodingError(Box<dyn std::error::Error + Send + Sync>); impl DecodingError { @@ -75,7 +75,7 @@ pub enum PgError { #[error("authentication failed for user '{0}'")] InvalidPassword(String), - #[error("{1}")] + #[error("PG {}: {1}", .0.as_str())] WithExplicitCode(PgErrorCode, String), // Server could not encode a value into client's format. @@ -102,7 +102,7 @@ pub enum PgError { IoError(#[from] io::Error), // TODO: exterminate this error. - #[error("{0}")] + #[error(transparent)] Other(Box<dyn std::error::Error>), } diff --git a/src/plugin/migration.rs b/src/plugin/migration.rs index e8bba352bc13427c8111cb4e08d1b3a917b5918c..abd9d3e0f68bb756c220d4d7bbe003cc42ef72cb 100644 --- a/src/plugin/migration.rs +++ b/src/plugin/migration.rs @@ -24,7 +24,7 @@ use tarantool::time::Instant; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("Error while open migration file `{0}`: {1}")] - File(String, io::Error), + File(String, #[source] io::Error), #[error("Failed spawning a migrations parsing thread: {0}")] Blocking(#[from] BlockingError), diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index 54f1775f1db5196fca92b9f9d1b4c1cbd5b01b7d..9c74b92be12be1057326e39e013598270b25036c 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -53,9 +53,9 @@ pub enum PluginError { #[error("Failed to update topology for plugin `{0}`: {}", DisplaySomeOrDefault(.1, "unknown reason"))] TopologyUpdateAborted(PluginIdentifier, Option<ErrorInfo>), #[error("Error while discovering manifest for plugin `{0}`: {1}")] - ManifestNotFound(String, io::Error), + ManifestNotFound(String, #[source] io::Error), #[error("Error while parsing manifest `{0}`, reason: {1}")] - InvalidManifest(String, Box<dyn std::error::Error>), + InvalidManifest(String, #[source] Box<dyn std::error::Error>), #[error("Read plugin_dir: {0}")] ReadPluginDir(#[from] io::Error), #[error("Invalid shared object file: {0}")] @@ -101,7 +101,7 @@ pub enum PluginError { #[error("Unexpected invalid configuration")] InvalidConfiguration, #[error("Invalid configuration value (should be a json string): {0}")] - ConfigDecode(serde_json::Error), + ConfigDecode(#[source] serde_json::Error), #[error( "Picoplugin version {0} used to build a plugin is incompatible with picodata version {}", PICODATA_VERSION diff --git a/src/rpc/ddl_apply.rs b/src/rpc/ddl_apply.rs index 8262d53ff5c27b81aed705cecee08d7870f41731..4b203fd9f4351c680c651a9c2e928965099e8143 100644 --- a/src/rpc/ddl_apply.rs +++ b/src/rpc/ddl_apply.rs @@ -118,10 +118,10 @@ crate::define_rpc_request! { pub enum Error { /// Schema change failed on this instance and should be aborted on the /// whole cluster. - #[error("{0}")] + #[error(transparent)] Aborted(TraftError), - #[error("{0}")] + #[error(transparent)] Other(TraftError), } diff --git a/src/schema.rs b/src/schema.rs index b8df4eccece6e6f17e65587123e4c78914a5d9c1..e2b5cfd51125f6bfcd7a21e249ec40490dda953d 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1700,13 +1700,13 @@ pub fn try_space_field_type_to_index_field_type( #[derive(Debug, thiserror::Error)] pub enum DdlError { - #[error("{0}")] + #[error(transparent)] CreateTable(#[from] CreateTableError), #[error("ddl operation was aborted: {0}")] Aborted(ErrorInfo), #[error("there is no pending ddl operation")] NoPendingDdl, - #[error("{0}")] + #[error(transparent)] CreateIndex(#[from] CreateIndexError), } diff --git a/src/traft/error.rs b/src/traft/error.rs index 8a3f76f18b5f8188336ec096ef547707368ee392..a34ead9421d8526dd431bdf9a035346484b48662 100644 --- a/src/traft/error.rs +++ b/src/traft/error.rs @@ -69,7 +69,7 @@ pub enum Error { Timeout, #[error("current instance is expelled from the cluster")] Expelled, - #[error("{0}")] + #[error(transparent)] Raft(#[from] raft::Error), #[error("downcast error: expected {expected:?}, actual: {actual:?}")] DowncastError { @@ -102,7 +102,7 @@ pub enum Error { NotALeader, #[error("lua error: {0}")] Lua(#[from] LuaError), - #[error("{0}")] + #[error(transparent)] Tarantool(#[from] ::tarantool::error::Error), #[error("instance with {} not found", *.0)] NoSuchInstance(IdOfInstance),