oxios_kernel/pty/
error.rs1use thiserror::Error;
3
4#[derive(Debug, Error)]
5pub enum PtyError {
6 #[error("pty subsystem is disabled in config")]
8 Disabled,
9
10 #[error("session cap reached for principal: max {max}")]
12 SessionCapReached { max: u32 },
13
14 #[error("shell not allowed: {shell:?}")]
16 ShellNotAllowed { shell: String },
17
18 #[error("failed to spawn pty: {0}")]
20 Spawn(String),
21
22 #[error("session not found: {0}")]
24 NotFound(String),
25
26 #[error("session {0} is closed")]
28 Closed(String),
29
30 #[error("session {0} not owned by caller")]
32 NotOwner(String),
33
34 #[error("pty io: {0}")]
36 Io(String),
37}
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 #[test]
44 fn display_messages() {
45 assert_eq!(
46 PtyError::Disabled.to_string(),
47 "pty subsystem is disabled in config"
48 );
49 assert_eq!(
50 PtyError::SessionCapReached { max: 3 }.to_string(),
51 "session cap reached for principal: max 3"
52 );
53 assert_eq!(
54 PtyError::ShellNotAllowed {
55 shell: "fish".into()
56 }
57 .to_string(),
58 "shell not allowed: \"fish\""
59 );
60 }
61}