win_hotkey/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use thiserror::Error;

use crate::hotkey::HotKey;

/// Errors returned by tray-icon.
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum Error {
    #[error(transparent)]
    OsError(#[from] std::io::Error),
    #[error("{0}")]
    HotKeyParseError(String),
    #[error("Couldn't recognize \"{0}\" as a valid HotKey Code, if you feel like it should be, please report this to https://github.com/tauri-apps/global-hotkey")]
    UnrecognizedHotKeyCode(String),
    #[error("Unexpected empty token while parsing hotkey: \"{0}\"")]
    EmptyHotKeyToken(String),
    #[error("Unexpected hotkey string format: \"{0}\", a hotkey should have the modifiers first and only contain one main key")]
    UnexpectedHotKeyFormat(String),
    #[error("{0}")]
    FailedToRegister(String),
    #[error("Failed to unregister hotkey: {0:?}")]
    FailedToUnRegister(HotKey),
    #[error("HotKey already registerd: {0:?}")]
    AlreadyRegistered(HotKey),
    #[error("Failed to watch media key event")]
    FailedToWatchMediaKeyEvent,
}

/// Convenient type alias of Result type for tray-icon.
pub type Result<T> = std::result::Result<T, Error>;