From fe2df6188464bdaea99e7861a7edc9391b3c7603 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 2 May 2025 13:16:31 +0900 Subject: [PATCH] winit-core: move error --- src/lib.rs | 6 +++--- src/os_error.rs | 6 ++++++ {src => winit-core/src}/error.rs | 5 ++--- winit-core/src/lib.rs | 2 ++ 4 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/os_error.rs rename {src => winit-core/src}/error.rs (97%) diff --git a/src/lib.rs b/src/lib.rs index ba115cad..4f3fd440 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,12 +299,12 @@ pub use rwh_06 as raw_window_handle; pub mod application; #[cfg(any(doc, doctest, test))] pub mod changelog; -#[macro_use] -pub mod error; use winit_core::cursor; pub mod event; pub mod event_loop; -pub use winit_core::{icon, keyboard, monitor}; +pub use winit_core::{error, icon, keyboard, monitor}; +#[macro_use] +mod os_error; mod platform_impl; use winit_core::as_any as utils; pub mod window; diff --git a/src/os_error.rs b/src/os_error.rs new file mode 100644 index 00000000..30281c8d --- /dev/null +++ b/src/os_error.rs @@ -0,0 +1,6 @@ +#[allow(unused_macros)] +macro_rules! os_error { + ($error:expr) => {{ + winit_core::error::OsError::new(line!(), file!(), $error) + }}; +} diff --git a/src/error.rs b/winit-core/src/error.rs similarity index 97% rename from src/error.rs rename to winit-core/src/error.rs index 697b37dd..39635639 100644 --- a/src/error.rs +++ b/winit-core/src/error.rs @@ -100,7 +100,7 @@ pub struct NotSupportedError { } impl NotSupportedError { - pub(crate) fn new(reason: &'static str) -> Self { + pub fn new(reason: &'static str) -> Self { Self { reason } } } @@ -121,8 +121,7 @@ pub struct OsError { } impl OsError { - #[allow(dead_code)] - pub(crate) fn new( + pub fn new( line: u32, file: &'static str, error: impl Into>, diff --git a/winit-core/src/lib.rs b/winit-core/src/lib.rs index 659e1a02..d29b6130 100644 --- a/winit-core/src/lib.rs +++ b/winit-core/src/lib.rs @@ -1,6 +1,8 @@ #[macro_use] pub mod as_any; pub mod cursor; +#[macro_use] +pub mod error; pub mod icon; pub mod keyboard; pub mod monitor;