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
59
60
61
62
63
64
65
66
67
//! Test: Invalid primary name should fail compilation
//!
//! This test verifies that diag! with strict(primary) validation
//! catches references to non-existent primary constants.
use waddling_errors_macros::{diag, primary, setup};
setup! {
components = crate::components,
primaries = crate::primaries,
sequences = crate::sequences,
}
// Define a dummy component module for setup! macro
pub mod components {
use waddling_errors_macros::component;
component! {
pub enum Component {
Auth {
docs: "Authentication",
},
}
}
}
// Define valid primaries
pub mod primaries {
use waddling_errors_macros::primary;
primary! {
pub enum Primary {
Token {
docs: "Authentication token errors",
tags: ["security"],
},
Permission {
docs: "Authorization errors",
tags: ["security"],
},
}
}
}
// Define a valid sequence for the test
pub mod sequences {
use waddling_errors_macros::sequence;
sequence! {
MISSING(1) {
description: "Required parameter missing",
typical_severity: "Error",
},
}
}
// This should FAIL because NonExistent primary is not defined
diag! {
strict(primary),
E.Auth.NonExistent.MISSING: {
message: "This should fail - NonExistent primary doesn't exist",
},
}
fn main() {}