1 use thiserror::Error; 2 3 macro_rules! error_type { 4 ($name:ident, $what:expr) => { 5 // Use #[error("invalid {}", $what)] instead. 6 7 #[derive(Error, Debug)] 8 #[error(concat!("invalid ", $what))] 9 pub struct $name; 10 }; 11 } 12 13 error_type!(Error, "foo"); 14 main()15 fn main() {} 16