ironflow_runtime/
error.rs1use thiserror::Error;
4use tokio_cron_scheduler::JobSchedulerError;
5
6#[derive(Debug, Error)]
8pub enum RuntimeError {
9 #[error("failed to bind address: {0}")]
11 Bind(std::io::Error),
12 #[error("cron scheduler error: {0}")]
14 Cron(#[from] JobSchedulerError),
15 #[error("http server error: {0}")]
17 Serve(std::io::Error),
18 #[error("scheduler shutdown error: {0}")]
20 Shutdown(JobSchedulerError),
21}
22
23#[cfg(test)]
24mod tests {
25 use super::*;
26
27 #[test]
28 fn bind_error_display() {
29 let err = RuntimeError::Bind(std::io::Error::new(
30 std::io::ErrorKind::AddrInUse,
31 "port taken",
32 ));
33 assert_eq!(err.to_string(), "failed to bind address: port taken");
34 }
35
36 #[test]
37 fn serve_error_display() {
38 let err = RuntimeError::Serve(std::io::Error::other("fatal"));
39 assert_eq!(err.to_string(), "http server error: fatal");
40 }
41
42 #[test]
43 fn runtime_error_implements_std_error() {
44 let err = RuntimeError::Bind(std::io::Error::other("x"));
45 let _: &dyn std::error::Error = &err;
46 }
47}