winres_edit/
error.rs

1//!
2//! Errors produced by this crate.
3//!
4
5use manual_serializer::Error as SerializerError;
6use std::string::FromUtf16Error;
7use thiserror::Error;
8
9/// Errors produced by this crate.
10#[derive(Debug, Error)]
11pub enum Error {
12    #[error("Error: {0}")]
13    String(String),
14
15    #[error("Error: {0}")]
16    FromUtf16Error(FromUtf16Error),
17
18    #[error("{0}")]
19    SerializerError(#[from] SerializerError),
20
21    #[error("{0}")]
22    Win32Error(::windows::core::Error),
23}
24
25impl From<String> for Error {
26    fn from(s: String) -> Error {
27        Error::String(s)
28    }
29}
30
31impl From<&str> for Error {
32    fn from(s: &str) -> Error {
33        Error::String(s.to_string())
34    }
35}
36
37impl From<FromUtf16Error> for Error {
38    fn from(e: FromUtf16Error) -> Error {
39        Error::FromUtf16Error(e)
40    }
41}
42
43impl From<::windows::core::Error> for Error {
44    fn from(e: ::windows::core::Error) -> Error {
45        Error::Win32Error(e)
46    }
47}