retroglyph_window/winit/
error.rs1use core::fmt;
4
5#[derive(Debug)]
17pub struct EventLoopError(::winit::error::EventLoopError);
18
19impl fmt::Display for EventLoopError {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 fmt::Display::fmt(&self.0, f)
22 }
23}
24
25impl std::error::Error for EventLoopError {
26 fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
27 Some(&self.0)
28 }
29}
30
31impl From<::winit::error::EventLoopError> for EventLoopError {
32 fn from(err: ::winit::error::EventLoopError) -> Self {
33 Self(err)
34 }
35}
36
37#[cfg(test)]
38mod tests {
39 use super::EventLoopError;
40
41 fn recreation_attempt() -> EventLoopError {
44 EventLoopError::from(::winit::error::EventLoopError::RecreationAttempt)
45 }
46
47 #[test]
48 fn display_matches_the_wrapped_winit_error() {
49 assert_eq!(
50 recreation_attempt().to_string(),
51 ::winit::error::EventLoopError::RecreationAttempt.to_string()
52 );
53 }
54
55 #[test]
56 fn source_reaches_the_wrapped_winit_error() {
57 let err = recreation_attempt();
58 let source = std::error::Error::source(&err).expect("wraps a source");
59 assert_eq!(
60 source.to_string(),
61 ::winit::error::EventLoopError::RecreationAttempt.to_string()
62 );
63 }
64}