2023-03-04 05:37:11 +01:00
|
|
|
use crate::futures;
|
|
|
|
|
use crate::graphics;
|
|
|
|
|
use crate::shell;
|
2020-09-08 00:35:17 +02:00
|
|
|
|
|
|
|
|
/// 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-04-26 19:28:04 -03:00
|
|
|
/// The application graphics context could not be created.
|
|
|
|
|
#[error("the application graphics context could not be created")]
|
2023-03-04 05:37:11 +01:00
|
|
|
GraphicsCreationFailed(graphics::Error),
|
2020-09-08 00:35:17 +02:00
|
|
|
}
|
|
|
|
|
|
2023-03-04 05:37:11 +01:00
|
|
|
impl From<shell::Error> for Error {
|
|
|
|
|
fn from(error: shell::Error) -> Error {
|
2020-09-08 00:35:17 +02:00
|
|
|
match error {
|
2023-03-04 05:37:11 +01:00
|
|
|
shell::Error::ExecutorCreationFailed(error) => {
|
2020-09-08 00:35:17 +02:00
|
|
|
Error::ExecutorCreationFailed(error)
|
|
|
|
|
}
|
2023-03-04 05:37:11 +01:00
|
|
|
shell::Error::WindowCreationFailed(error) => {
|
2020-09-08 00:35:17 +02:00
|
|
|
Error::WindowCreationFailed(Box::new(error))
|
|
|
|
|
}
|
2023-03-04 05:37:11 +01:00
|
|
|
shell::Error::GraphicsCreationFailed(error) => {
|
2022-04-26 19:28:04 -03:00
|
|
|
Error::GraphicsCreationFailed(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>();
|
|
|
|
|
}
|
|
|
|
|
}
|