1use crate::types::{ApiBackend, FrameFormat};
18use thiserror::Error;
19
20#[allow(clippy::module_name_repetitions)]
22#[derive(Error, Debug, Clone)]
23pub enum NokhwaError {
24 #[error("Unitialized Camera. Call `init()` first!")]
25 UnitializedError,
26 #[error("Could not initialize {backend}: {error}")]
27 InitializeError { backend: ApiBackend, error: String },
28 #[error("Could not shutdown {backend}: {error}")]
29 ShutdownError { backend: ApiBackend, error: String },
30 #[error("Error: {0}")]
31 GeneralError(String),
32 #[error("Could not generate required structure {structure}: {error}")]
33 StructureError { structure: String, error: String },
34 #[error("Could not open device {0}: {1}")]
35 OpenDeviceError(String, String),
36 #[error("Could not get device property {property}: {error}")]
37 GetPropertyError { property: String, error: String },
38 #[error("Could not set device property {property} with value {value}: {error}")]
39 SetPropertyError {
40 property: String,
41 value: String,
42 error: String,
43 },
44 #[error("Could not open device stream: {0}")]
45 OpenStreamError(String),
46 #[error("Could not capture frame: {0}")]
47 ReadFrameError(String),
48 #[error("Could not process frame {src} to {destination}: {error}")]
49 ProcessFrameError {
50 src: FrameFormat,
51 destination: String,
52 error: String,
53 },
54 #[error("Could not stop stream: {0}")]
55 StreamShutdownError(String),
56 #[error("This operation is not supported by backend {0}.")]
57 UnsupportedOperationError(ApiBackend),
58 #[error("This operation is not implemented yet: {0}")]
59 NotImplementedError(String),
60}