Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crates/core_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions crates/core_types/src/bits_n_pieces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
13 changes: 8 additions & 5 deletions crates/core_types/src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -54,6 +54,7 @@ impl CoreError {
kind: hc_err,
file: String::new(),
line: String::new(),
backtrace: Backtrace::new(),
}
}
}
Expand All @@ -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
)
}
}
Expand Down Expand Up @@ -435,6 +436,7 @@ mod tests {
kind: error.clone(),
file: file!().to_string(),
line: line!().to_string(),
backtrace: Backtrace::new(),
};

assert_ne!(
Expand All @@ -443,6 +445,7 @@ mod tests {
kind: error,
file: file!().to_string(),
line: line!().to_string(),
backtrace: Backtrace::new(),
}
.to_string(),
);
Expand Down
1 change: 1 addition & 0 deletions crates/wasm_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 2 additions & 0 deletions crates/wasm_utils/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ macro_rules! core_error {
kind: $hc_err,
file: file!().to_string(),
line: line!().to_string(),
backtrace: backtrace::Backtrace::new(),
}
};
}
Expand All @@ -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(),
}
};
}