icentral_errors/
betweenness_centrality_errors.rs1crate::ix!();
2
3pub type BCMaybeSuccess = Result<(),BetweennessCentralityError>;
4
5error_tree!{
6
7 pub enum BetweennessCentralityError {
8
9 DataMismatch {
10 msg: String,
11 },
12
13 DuplicateEdgeInsertion {
14 edge: Edge,
15 },
16
17 DataMismatches {
18 mismatches: Vec<f64>,
19 },
20
21 NoKey {
22 key: usize
23 },
24
25 Poisoned {
26 msg: String
27 },
28
29 TryFromIntError(std::num::TryFromIntError),
30 IoError(std::io::Error),
31 TextIoError(text_io::Error),
32 ParseIntError(ParseIntError),
33 NoMPI,
34 LockError {
35 msg: String,
36 },
37 }
38
39 pub enum ParallelICentralError {
40 Io(std::io::Error),
41 TryFromIntError(std::num::TryFromIntError),
42 }
43}
44
45impl BetweennessCentralityError {
46
47 pub fn no_key(x: usize) -> Self {
48 BetweennessCentralityError::NoKey { key: x }
49 }
50
51 pub fn mismatch_diff(diff: f64, msg: Option<&str>) -> Self {
52
53 BetweennessCentralityError::DataMismatch {
54 msg: format!("data mismatch diff: {}, msg: {:?}", diff, msg)
55 }
56 }
57}
58
59pub trait PoisonMessage {
60
61 fn poison_message(&self) -> String;
62}
63
64impl<'a, T: PoisonMessage>
65 From<std::sync::PoisonError<MutexGuard<'a,T>>>
66 for BetweennessCentralityError
67{
68 fn from(x: std::sync::PoisonError<MutexGuard<'a,T>>) -> Self {
69
70 BetweennessCentralityError::Poisoned {
71 msg: x.into_inner().poison_message()
72 }
73 }
74}
75
76impl<T: core::fmt::Debug> PoisonMessage for T {
77 fn poison_message(&self) -> String {
78 format!("poisoned {:?}!",self)
79 }
80}
81
82pub type BCError = BetweennessCentralityError;
83