Skip to main content

rm_lisa/
errors.rs

1//! List of all errors for this crate.
2
3use serde_json::Error as JsonError;
4use std::{
5	fmt::Error as FmtError, io::Error as IoError, net::AddrParseError, string::FromUtf8Error,
6};
7use thiserror::Error;
8#[cfg(target_os = "windows")]
9use widestring::error::Utf16Error;
10#[cfg(target_os = "windows")]
11use windows::{Win32::Foundation::WIN32_ERROR, core::Error as WindowsError};
12
13/// All errors that can come out of this crate.
14///
15/// This is marked as non-exhaustive as there are errors that only end up
16/// appearing on Windows. So to ensure proper handling always, we force
17/// non-exhaustive.
18#[derive(Debug, Error)]
19#[non_exhaustive]
20pub enum LisaError {
21	#[error("A crate-wide logger has already been initialized!")]
22	AlreadyRegistered,
23	#[error("Cannot Parse `{0}_TOKIO_CONSOLE_URI`: {1:?}")]
24	InvalidTokioConsoleURI(&'static str, AddrParseError),
25	#[error("Host I/O error: {0:?}")]
26	IOError(#[from] IoError),
27	#[error("Error serializing JSON: {0:?}")]
28	JSONError(#[from] JsonError),
29	#[error("Formatting error: {0:?}")]
30	FormatError(#[from] FmtError),
31	#[error(
32		"Could not find a renderer that was compatible to render log lines, please file an issue."
33	)]
34	NoRendererFound,
35	#[error("Value is not an appropriate remap value: [{0}]")]
36	RemapError(String),
37	#[error("Error reading input in as UTF-8: {0:?}")]
38	UTF8(#[from] FromUtf8Error),
39	#[cfg(target_os = "windows")]
40	#[error("Underlying windows error: {0:?}")]
41	Windows(#[from] WindowsError),
42	#[cfg(target_os = "windows")]
43	#[error("Underlying Win32 Error: {0:?}")]
44	Win32(WIN32_ERROR),
45	#[cfg(target_os = "windows")]
46	#[error("Error converting Windows UTF16 string to UTF8 string.")]
47	UTF16ToUTF8Error(#[from] Utf16Error),
48}