windows_api_utils/
error.rs

1//! Error types for Windows API utilities.
2//!
3//! This module provides error types that are always available,
4//! regardless of which features are enabled.
5
6#[cfg(feature = "std")]
7use thiserror::Error;
8
9/// Errors that can occur in Windows API utilities.
10#[cfg_attr(feature = "std", derive(Error))]
11#[cfg_attr(not(feature = "std"), derive(Debug, Clone, PartialEq))]
12#[derive(Debug, Clone, PartialEq)]
13pub enum WindowsUtilsError {
14    /// Invalid coordinates provided.
15    #[cfg_attr(feature = "std", error("Invalid coordinates: ({x}, {y})"))]
16    InvalidCoordinates {
17        /// X coordinate
18        x: i32,
19        /// Y coordinate
20        y: i32,
21    },
22
23    /// Point is outside the window bounds.
24    #[cfg_attr(feature = "std", error("Point ({x}, {y}) is outside window bounds"))]
25    OutOfBounds {
26        /// X coordinate
27        x: i32,
28        /// Y coordinate
29        y: i32,
30    },
31
32    /// Invalid window handle.
33    #[cfg_attr(feature = "std", error("Invalid window handle: {handle}"))]
34    InvalidWindowHandle {
35        /// Window handle
36        handle: isize,
37    },
38
39    /// Invalid message parameter.
40    #[cfg_attr(feature = "std", error("Invalid message parameter: {parameter}"))]
41    InvalidMessageParameter {
42        /// Parameter description
43        parameter: &'static str, // Changed from String to &'static str for no_std
44    },
45
46    /// Unsupported message type.
47    #[cfg_attr(feature = "std", error("Unsupported message type: 0x{message:x}"))]
48    UnsupportedMessage {
49        /// Message ID
50        message: u32,
51    },
52
53    /// Feature not enabled.
54    #[cfg_attr(feature = "std", error("Required feature not enabled: {feature}"))]
55    FeatureNotEnabled {
56        /// Required feature name
57        feature: &'static str,
58    },
59}
60
61/// Result type for Windows API utilities.
62pub type WindowsUtilsResult<T> = Result<T, WindowsUtilsError>;