1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#[macro_export]
macro_rules! zome_assert {
($stack:ident, $cond:expr) => {
if !$cond {
let error_report =
core_error_generic!(format!(r#"Zome assertion failed: `{}`"#, stringify!($cond)));
return return_code_for_allocation_result($stack.write_json(error_report)).into();
}
};
}
#[macro_export]
macro_rules! ribosome_success {
() => {
Ok(Some(RuntimeValue::I64(
$crate::holochain_core_types::error::RibosomeRuntimeBits::from(
$crate::holochain_core_types::error::RibosomeEncodedValue::Success,
),
)))
};
}
#[macro_export]
macro_rules! ribosome_error_code {
($s:ident) => {
Ok(Some(RuntimeValue::I64(
$crate::holochain_core_types::error::RibosomeErrorCode::$s
as $crate::holochain_core_types::error::RibosomeRuntimeBits,
)))
};
}
#[macro_export]
macro_rules! core_error {
($hc_err:expr) => {
$crate::holochain_core_types::error::CoreError {
kind: $hc_err,
file: file!().to_string(),
line: line!().to_string(),
}
};
}
#[macro_export]
macro_rules! core_error_generic {
($msg:expr) => {
$crate::holochain_core_types::error::CoreError {
kind: $crate::holochain_core_types::error::HolochainError::ErrorGeneric($msg),
file: file!().to_string(),
line: line!().to_string(),
}
};
}