1use std::error;
2use std::fmt;
3use std::io;
4
5use crate::EventError;
6
7#[derive(Debug)]
11pub enum EmitterError {
12 IoError(io::Error),
14
15 LibYamlError,
17}
18
19impl From<EventError> for EmitterError {
20 fn from(_: EventError) -> Self {
21 Self::LibYamlError
22 }
23}
24
25impl fmt::Display for EmitterError {
26 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
27 write!(f, "YAML emitter error")
28 }
29}
30
31impl error::Error for EmitterError {
32 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
33 match self {
34 Self::IoError(io_error) => Some(io_error),
35 Self::LibYamlError => None,
36 }
37 }
38}