wayland_protocols_async/ext_session_lock_v1/
errors.rs1use std::fmt;
2
3#[derive(Debug, Default, Clone, Copy)]
4pub enum SessionLockhandlerErrorCodes {
5 #[default]
6 UnknownError,
7 ManagerIsNotSet,
8 WLOutputIsNotSet,
9 WLSurfaceIsNotSet,
10 SessionLockIsNotSet,
11 SessionLockSurfaceIsNotSet,
12 SessionLockSurfaceSerialIsNotSet,
13}
14
15impl fmt::Display for SessionLockhandlerErrorCodes {
16 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
17 match self {
18 SessionLockhandlerErrorCodes::UnknownError => write!(f, "SessionLockhandlerErrorCodes: UnknownError"),
19 SessionLockhandlerErrorCodes::ManagerIsNotSet => write!(f, "SessionLockhandlerErrorCodes: ManagerIsNotSet"),
20 SessionLockhandlerErrorCodes::WLOutputIsNotSet => write!(f, "SessionLockhandlerErrorCodes: NoWLOutputFound"),
21 SessionLockhandlerErrorCodes::WLSurfaceIsNotSet => write!(f, "SessionLockhandlerErrorCodes: WLSurfaceIsNotSet"),
22 SessionLockhandlerErrorCodes::SessionLockIsNotSet => write!(f, "SessionLockhandlerErrorCodes: SessionLockIsNotSet"),
23 SessionLockhandlerErrorCodes::SessionLockSurfaceIsNotSet => write!(f, "SessionLockhandlerErrorCodes: SessionLockSurfaceIsNotSet"),
24 SessionLockhandlerErrorCodes::SessionLockSurfaceSerialIsNotSet => write!(f, "SessionLockhandlerErrorCodes: SessionLockSurfaceSerialIsNotSet"),
25 }
26 }
27}
28
29#[derive(Debug)]
30pub struct SessionLockhandlerError {
31 pub code: SessionLockhandlerErrorCodes,
32 pub message: String,
33}
34
35impl std::fmt::Display for SessionLockhandlerError {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 write!(
38 f,
39 "SessionLockhandlerErrorCodes:(code: {:?}, message: {})",
40 self.code, self.message
41 )
42 }
43}
44
45impl SessionLockhandlerError {
46 pub fn new(code: SessionLockhandlerErrorCodes, message: String) -> Self {
47 Self { code, message }
48 }
49}