2020-09-08 00:35:17 +02:00
|
|
|
use iced_futures::futures;
|
|
|
|
|
|
|
|
|
|
/// 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")]
|
2021-01-29 14:03:27 +09:00
|
|
|
WindowCreationFailed(Box<dyn std::error::Error + Send + Sync>),
|
2020-09-08 00:35:17 +02:00
|
|
|
|
2022-01-27 04:00:53 -03:00
|
|
|
/// The application context could not be created.
|
|
|
|
|
#[error("the application context could not be created")]
|
|
|
|
|
ContextCreationFailed(iced_graphics::Error),
|
2020-09-08 00:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl From<iced_winit::Error> for Error {
|
|
|
|
|
fn from(error: iced_winit::Error) -> Error {
|
|
|
|
|
match error {
|
|
|
|
|
iced_winit::Error::ExecutorCreationFailed(error) => {
|
|
|
|
|
Error::ExecutorCreationFailed(error)
|
|
|
|
|
}
|
|
|
|
|
iced_winit::Error::WindowCreationFailed(error) => {
|
|
|
|
|
Error::WindowCreationFailed(Box::new(error))
|
|
|
|
|
}
|
2022-01-27 04:00:53 -03:00
|
|
|
iced_winit::Error::ContextCreationFailed(error) => {
|
|
|
|
|
Error::ContextCreationFailed(error)
|
2020-09-08 00:35:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-29 14:03:27 +09:00
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn assert_send_sync() {
|
|
|
|
|
fn _assert<T: Send + Sync>() {}
|
|
|
|
|
_assert::<Error>();
|
|
|
|
|
}
|
|
|
|
|
}
|