refix_dictionary/transport/
error.rs1use crate::Tag;
2use std::fmt;
3
4#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Error {
8 ApplicationHeader,
10 ApplicationTrailer,
12 NoTransportHeader,
14 FieldMismatch {
17 application: (String, Tag),
18 transport: (String, Tag),
19 },
20}
21
22impl fmt::Display for Error {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Error::ApplicationHeader => {
26 write!(f, "the application dictionary has a header of its own")
27 }
28 Error::ApplicationTrailer => {
29 write!(f, "the application dictionary has a trailer of its own")
30 }
31 Error::NoTransportHeader => write!(f, "the transport dictionary has no header"),
32 Error::FieldMismatch {
33 application,
34 transport,
35 } => write!(
36 f,
37 "field '{}' ({}) in the application dictionary is '{}' ({}) in the transport",
38 application.0, application.1, transport.0, transport.1
39 ),
40 }
41 }
42}
43
44impl std::error::Error for Error {}