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