1use thiserror::Error;
2
3pub type Result<T> = std::result::Result<T, Error>;
5
6#[derive(Debug, Error)]
9pub enum Error {
10 #[error("encoding/decoding error: {0}")]
12 Codec(#[from] recode::Error),
13
14 #[error("invalid value for `$path`: {message}")]
16 InvalidValue {
17 path: &'static str,
18 message: &'static str,
19 },
20
21 #[error("missing value of `{frame_type} :: {field}'")]
24 MissingFieldValue {
25 frame_type: crate::FrameType,
26 field: &'static str,
27 },
28
29 #[error("unexpected flag `{flag:10b}' in `{frame_type}': {message}")]
31 UnexpectedFlag {
32 flag: crate::FrameFlags,
33 frame_type: crate::FrameType,
34 message: &'static str,
35 },
36
37 #[error("missing flag `{flag}' in `{frame_type}': {message}")]
39 MissingFlag {
40 flag: crate::FrameFlags,
41 frame_type: crate::FrameType,
42 message: &'static str,
43 },
44
45 #[error("invalid frame (`IGNORE` flag set): {0}")]
46 IgnoreableFrame(Box<Error>),
47}
48
49impl From<std::convert::Infallible> for Error {
50 fn from(_: std::convert::Infallible) -> Self {
51 unreachable!()
52 }
53}