fse_schema/error.rs
1use std::fmt;
2
3/// A schema error: unparseable source, an unsupported type, an invalid
4/// attribute combination or an unresolvable reference. Always carries a
5/// message that names the offending struct/field so the CLI and the derive
6/// can surface it directly.
7#[derive(Debug, Clone)]
8pub struct Error {
9 pub message: String,
10}
11
12impl Error {
13 pub fn new(message: impl Into<String>) -> Self {
14 Self {
15 message: message.into(),
16 }
17 }
18}
19
20impl fmt::Display for Error {
21 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22 f.write_str(&self.message)
23 }
24}
25
26impl std::error::Error for Error {}