diff --git a/Cargo.lock b/Cargo.lock index d48fa6e3a7..5fc906caba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -94,6 +94,8 @@ dependencies = [ "cfg-if", "libc", "rustc-demangle", + "serde", + "serde_derive", ] [[package]] @@ -1460,6 +1462,7 @@ dependencies = [ name = "holochain_core" version = "0.0.44-alpha3" dependencies = [ + "backtrace", "base64 0.10.1", "bitflags", "boolinator", @@ -1900,6 +1903,7 @@ dependencies = [ name = "holochain_wasm_utils" version = "0.0.44-alpha3" dependencies = [ + "backtrace", "holochain_conductor_lib", "holochain_core", "holochain_core_types", @@ -4471,9 +4475,9 @@ dependencies = [ [[package]] name = "sized-chunks" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfebcc1ad7f8439bff83ff95656c83bd9e4e832630bc9bb7c59774d0bc526b92" +checksum = "d59044ea371ad781ff976f7b06480b9f0180e834eda94114f2afb4afc12b7718" dependencies = [ "bitmaps", "typenum", diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 0b427b8d6d..3453bcdfb0 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -59,6 +59,7 @@ threadpool = "=1.7.1" im = { version = "=14.0.0", features = ["serde"] } itertools = "0.8.2" newrelic = { version = "=0.2.2", optional = true } +backtrace = { version = "=0.3.27", features = [ "serialize-serde" ] } [dev-dependencies] wabt = "=0.7.4" diff --git a/crates/core_types/Cargo.toml b/crates/core_types/Cargo.toml index 7f10bcd6ac..14e6b4c776 100644 --- a/crates/core_types/Cargo.toml +++ b/crates/core_types/Cargo.toml @@ -14,7 +14,7 @@ repository = "https://github.com/holochain/holochain-rust" futures = "=0.3.2" arrayref = "=0.3.5" base64 = "=0.10.1" -backtrace = "=0.3.27" +backtrace = { version = "=0.3.27", features = [ "serialize-serde" ] } chrono = "=0.4.6" serde = "=1.0.104" serde_derive = "=1.0.104" diff --git a/crates/core_types/src/bits_n_pieces.rs b/crates/core_types/src/bits_n_pieces.rs index 4d142a5c1e..b3ae1608b0 100644 --- a/crates/core_types/src/bits_n_pieces.rs +++ b/crates/core_types/src/bits_n_pieces.rs @@ -8,7 +8,7 @@ pub fn u32_high_bits(i: u32) -> u16 { /// returns the u16 low bits from a u32 by doing a lossy cast pub fn u32_low_bits(i: u32) -> u16 { - (i as u16) + i as u16 } /// splits the high and low bits of u32 into a tuple of u16, for destructuring convenience @@ -26,7 +26,7 @@ pub fn u64_high_bits(i: u64) -> u32 { } pub fn u64_low_bits(i: u64) -> u32 { - (i as u32) + i as u32 } pub fn u64_split_bits(i: u64) -> (u32, u32) { diff --git a/crates/core_types/src/error/mod.rs b/crates/core_types/src/error/mod.rs index 0ca2500451..c6de12fa8c 100644 --- a/crates/core_types/src/error/mod.rs +++ b/crates/core_types/src/error/mod.rs @@ -15,6 +15,7 @@ use holochain_locksmith::LocksmithError; use holochain_persistence_api::{error::PersistenceError, hash::HashString}; use lib3h_crypto_api::CryptoError; +use backtrace::Backtrace; use serde_json::Error as SerdeError; use std::{ error::Error, @@ -32,13 +33,12 @@ use std::{ /// and back to the Holochain Instance via wasm memory. /// Follows the Error + ErrorKind pattern /// Holds extra debugging info for indicating where in code ther error occured. -#[derive(Clone, Debug, Serialize, Deserialize, DefaultJson, PartialEq, Eq, Hash)] +#[derive(Clone, Debug, Serialize, Deserialize, DefaultJson)] pub struct CoreError { pub kind: HolochainError, pub file: String, pub line: String, - // TODO #395 - Add advance error debugging info - // pub stack_trace: Backtrace + pub backtrace: Backtrace, } // Error trait by using the inner Error @@ -54,6 +54,7 @@ impl CoreError { kind: hc_err, file: String::new(), line: String::new(), + backtrace: Backtrace::new(), } } } @@ -80,8 +81,8 @@ impl fmt::Display for CoreError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, - "Holochain Core error: {}\n --> {}:{}\n", - self.kind, self.file, self.line, + "Holochain Core error: {}\n --> {}:{}\nbacktrace: {:?}", + self.kind, self.file, self.line, self.backtrace ) } } @@ -435,6 +436,7 @@ mod tests { kind: error.clone(), file: file!().to_string(), line: line!().to_string(), + backtrace: Backtrace::new(), }; assert_ne!( @@ -443,6 +445,7 @@ mod tests { kind: error, file: file!().to_string(), line: line!().to_string(), + backtrace: Backtrace::new(), } .to_string(), ); diff --git a/crates/wasm_utils/Cargo.toml b/crates/wasm_utils/Cargo.toml index b918661a71..9dbbd11b66 100644 --- a/crates/wasm_utils/Cargo.toml +++ b/crates/wasm_utils/Cargo.toml @@ -15,6 +15,7 @@ holochain_core_types = { version = "=0.0.44-alpha3", path = "../core_types" } holochain_json_derive = "=0.0.23" holochain_persistence_api = "=0.0.18" holochain_json_api = "=0.0.23" +backtrace = { version = "=0.3.27", features = [ "serialize-serde" ] } [dev-dependencies] test_utils = { version = "=0.0.44-alpha3", path = "../../test_utils" } diff --git a/crates/wasm_utils/src/macros.rs b/crates/wasm_utils/src/macros.rs index e11704e4b6..fed79d4e70 100644 --- a/crates/wasm_utils/src/macros.rs +++ b/crates/wasm_utils/src/macros.rs @@ -41,6 +41,7 @@ macro_rules! core_error { kind: $hc_err, file: file!().to_string(), line: line!().to_string(), + backtrace: backtrace::Backtrace::new(), } }; } @@ -53,6 +54,7 @@ macro_rules! core_error_generic { kind: $crate::holochain_core_types::error::HolochainError::ErrorGeneric($msg), file: file!().to_string(), line: line!().to_string(), + backtrace: backtrace::Backtrace::new(), } }; }