rm_lisa/
errors.rs

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