flwrs_plugin/plugin/
error.rs1use prost::DecodeError;
2use std::fmt::{Display, Formatter};
3
4#[derive(thiserror::Error, Debug)]
5pub enum Error {
6 #[error("I/O error: {0}")]
7 IOError(#[from] std::io::Error),
8 #[error("Initialize error: {0}")]
9 InitError(#[from] InitializeError),
10 #[error("Shutdown error: {0}")]
11 ShutdownError(#[from] ShutdownError),
12 #[error("Sink error: {0}")]
13 SinkError(#[from] SinkError),
14 #[error("Source error: {0}")]
15 SourceError(#[from] SourceError),
16 #[error("Failed to set logger: {0}")]
17 SetLoggerError(#[from] log::SetLoggerError),
18 #[error("Invalid message: {0}")]
19 InvalidMessage(#[from] DecodeError),
20}
21
22#[derive(Debug)]
23pub struct InitializeError {
24 pub source: Box<dyn std::error::Error>,
25}
26
27impl Display for InitializeError {
28 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
29 f.write_str(&self.source.to_string())
30 }
31}
32
33impl std::error::Error for InitializeError {
34 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
35 Some(&*self.source)
36 }
37}
38
39#[derive(Debug)]
40pub struct ShutdownError {
41 pub source: Box<dyn std::error::Error>,
42}
43
44impl Display for ShutdownError {
45 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
46 f.write_str(&self.source.to_string())
47 }
48}
49
50impl std::error::Error for ShutdownError {
51 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
52 Some(&*self.source)
53 }
54}
55
56#[derive(Debug)]
57pub struct SinkError {
58 pub source: Box<dyn std::error::Error>,
59}
60
61impl Display for SinkError {
62 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
63 f.write_str(&self.source.to_string())
64 }
65}
66
67impl std::error::Error for SinkError {
68 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
69 Some(&*self.source)
70 }
71}
72
73#[derive(Debug)]
74pub struct SourceError {
75 pub source: Box<dyn std::error::Error>,
76}
77
78impl Display for SourceError {
79 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
80 f.write_str(&self.source.to_string())
81 }
82}
83
84impl std::error::Error for SourceError {
85 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
86 Some(&*self.source)
87 }
88}
89
90#[derive(Debug)]
91pub struct TransformError {
92 pub source: Box<dyn std::error::Error>,
93}
94
95impl Display for TransformError {
96 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
97 f.write_str(&self.source.to_string())
98 }
99}
100
101impl std::error::Error for TransformError {
102 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
103 Some(&*self.source)
104 }
105}