iced-yoda/src/error.rs
Ashley Wulber 757d0753ad
cleanup
2026-01-21 13:51:35 -05:00

54 lines
1.6 KiB
Rust

use crate::futures;
use crate::graphics;
#[cfg(feature = "winit")]
use crate::shell;
/// An error that occurred while running an application.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// The futures executor could not be created.
#[error("the futures executor could not be created")]
ExecutorCreationFailed(futures::io::Error),
/// The application window could not be created.
#[error("the application window could not be created")]
WindowCreationFailed(Box<dyn std::error::Error + Send + Sync>),
/// The application graphics context could not be created.
#[error("the application graphics context could not be created")]
GraphicsCreationFailed(graphics::Error),
/// There was an event loop error.
#[error("there was an event loop error")]
EventLoop(Box<dyn std::error::Error + Send + Sync>),
}
#[cfg(feature = "winit")]
impl From<shell::Error> for Error {
fn from(error: shell::Error) -> Error {
match error {
shell::Error::ExecutorCreationFailed(error) => {
Error::ExecutorCreationFailed(error)
}
#[cfg(feature = "winit")]
shell::Error::WindowCreationFailed(error) => {
Error::WindowCreationFailed(Box::new(error))
}
shell::Error::GraphicsCreationFailed(error) => {
Error::GraphicsCreationFailed(error)
}
shell::Error::EventLoop(error) => Error::EventLoop(Box::new(error)),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn assert_send_sync() {
fn _assert<T: Send + Sync>() {}
_assert::<Error>();
}
}