encounter_argumentation/
error.rs1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum Error {
8 #[error("scheme not found: {0}")]
10 SchemeNotFound(String),
11
12 #[error("missing binding for scheme {scheme}: slot {slot}")]
14 MissingBinding {
15 scheme: String,
17 slot: String,
19 },
20
21 #[error("scheme error: {0}")]
23 Scheme(#[from] argumentation_schemes::Error),
24
25 #[error("core argumentation error: {0}")]
27 Dung(#[from] argumentation::Error),
28
29 #[error("bipolar error: {0}")]
31 Bipolar(#[from] argumentation_bipolar::Error),
32
33 #[error("weighted error: {0}")]
35 Weighted(#[from] argumentation_weighted::Error),
36
37 #[error("weighted-bipolar error: {0}")]
39 WeightedBipolar(#[from] argumentation_weighted_bipolar::Error),
40
41 #[error("acceptance eval could not find a 'self' binding on affordance {affordance_name}")]
48 MissingProposerBinding {
49 affordance_name: String,
51 },
52}
53
54#[cfg(test)]
55mod tests {
56 use super::*;
57
58 #[test]
59 fn error_from_bipolar_propagates() {
60 let bipolar_err = argumentation_bipolar::Error::IllegalSelfSupport("x".into());
61 let err: Error = bipolar_err.into();
62 assert!(matches!(err, Error::Bipolar(_)));
63 }
64
65 #[test]
66 fn error_from_weighted_propagates() {
67 let weighted_err = argumentation_weighted::Error::InvalidWeight { weight: -1.0 };
68 let err: Error = weighted_err.into();
69 assert!(matches!(err, Error::Weighted(_)));
70 }
71
72 #[test]
73 fn error_from_wbipolar_propagates() {
74 let wbp_err = argumentation_weighted_bipolar::Error::IllegalSelfSupport;
75 let err: Error = wbp_err.into();
76 assert!(matches!(err, Error::WeightedBipolar(_)));
77 }
78
79 #[test]
80 fn error_from_dung_propagates() {
81 let core_err = argumentation::Error::TooLarge { arguments: 100, limit: 22 };
83 let err: Error = core_err.into();
84 assert!(matches!(err, Error::Dung(_)));
85 }
86}