rmp_ipc/events/
error_event.rs

1use serde::{Deserialize, Serialize};
2use std::error::Error;
3use std::fmt::{Display, Formatter};
4
5pub static ERROR_EVENT_NAME: &str = "error";
6
7/// Data returned on error event.
8/// The error event has a default handler that just logs that
9/// an error occurred. For a custom handler, register a handler on
10/// the [ERROR_EVENT_NAME] event.
11#[derive(Clone, Deserialize, Serialize, Debug)]
12pub struct ErrorEventData {
13    pub code: u16,
14    pub message: String,
15}
16
17impl Error for ErrorEventData {}
18
19impl Display for ErrorEventData {
20    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
21        write!(f, "IPC Code {}: '{}'", self.code, self.message)
22    }
23}