Propagate error from EventLoop creation
Inner panics could make it hard to trouble shoot the issues and for some users ints not desirable. The inner panics were left only when they are used to `assert!` during development.
This commit is contained in:
parent
584aab4cd0
commit
ed26dd58fd
57 changed files with 344 additions and 291 deletions
|
|
@ -64,7 +64,7 @@ use self::{
|
|||
};
|
||||
use super::{common::xkb_state::KbdState, OsError};
|
||||
use crate::{
|
||||
error::{OsError as RootOsError, RunLoopError},
|
||||
error::{EventLoopError, OsError as RootOsError},
|
||||
event::{Event, StartCause},
|
||||
event_loop::{ControlFlow, DeviceEvents, EventLoopClosed, EventLoopWindowTarget as RootELW},
|
||||
platform::pump_events::PumpStatus,
|
||||
|
|
@ -432,12 +432,12 @@ impl<T: 'static> EventLoop<T> {
|
|||
&self.target
|
||||
}
|
||||
|
||||
pub fn run_ondemand<F>(&mut self, mut event_handler: F) -> Result<(), RunLoopError>
|
||||
pub fn run_ondemand<F>(&mut self, mut event_handler: F) -> Result<(), EventLoopError>
|
||||
where
|
||||
F: FnMut(Event<T>, &RootELW<T>, &mut ControlFlow),
|
||||
{
|
||||
if self.loop_running {
|
||||
return Err(RunLoopError::AlreadyRunning);
|
||||
return Err(EventLoopError::AlreadyRunning);
|
||||
}
|
||||
|
||||
let exit = loop {
|
||||
|
|
@ -446,7 +446,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
break Ok(());
|
||||
}
|
||||
PumpStatus::Exit(code) => {
|
||||
break Err(RunLoopError::ExitFailure(code));
|
||||
break Err(EventLoopError::ExitFailure(code));
|
||||
}
|
||||
_ => {
|
||||
continue;
|
||||
|
|
@ -460,7 +460,7 @@ impl<T: 'static> EventLoop<T> {
|
|||
// X Server.
|
||||
let wt = get_xtarget(&self.target);
|
||||
wt.x_connection().sync_with_server().map_err(|x_err| {
|
||||
RunLoopError::Os(os_error!(OsError::XError(Arc::new(X11Error::Xlib(x_err)))))
|
||||
EventLoopError::Os(os_error!(OsError::XError(Arc::new(X11Error::Xlib(x_err)))))
|
||||
})?;
|
||||
|
||||
exit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue