1use std::path::PathBuf;
4use thiserror::Error;
5
6#[derive(Debug, Error)]
8pub enum HapError {
9 #[error("entity not found: {0}")]
10 EntityNotFound(String),
11
12 #[error("entity {entity_id} cannot be mapped to a HAP accessory type: {reason}")]
13 UnmappableEntity { entity_id: String, reason: String },
14
15 #[error("accessory already registered: {0}")]
16 AlreadyRegistered(String),
17
18 #[error("mDNS advertiser error: {0}")]
19 MdnsError(String),
20
21 #[error("bridge not running")]
22 NotRunning,
23
24 #[error("pairing store error: {0}")]
25 PairingStore(String),
26
27 #[error("invalid pairing record: {0}")]
28 InvalidPairingRecord(String),
29
30 #[error("controller pairing already exists: {0}")]
31 PairingAlreadyExists(String),
32
33 #[error("controller pairing not found: {0}")]
34 PairingNotFound(String),
35
36 #[error("maximum controller pairings reached")]
37 PairingCapacity,
38
39 #[error("insecure permissions on {path}: mode {mode:o}; expected no group/other access")]
40 InsecurePermissions { path: PathBuf, mode: u32 },
41
42 #[error("invalid HAP session transition from {from} to {to}")]
43 InvalidSessionTransition {
44 from: &'static str,
45 to: &'static str,
46 },
47
48 #[error("HAP protocol error: {0}")]
49 Protocol(String),
50
51 #[error("HAP server error: {0}")]
52 Server(String),
53}