dialoguer_ext/error.rs
1use std::{io::Error as IoError, result::Result as StdResult};
2
3use thiserror::Error;
4
5/// Possible errors returned by prompts.
6#[derive(Error, Debug)]
7pub enum Error {
8 /// Error while executing IO operations.
9 #[error("IO error: {0}")]
10 IO(#[from] IoError),
11}
12
13/// Result type where errors are of type [Error](enum@Error).
14pub type Result<T = ()> = StdResult<T, Error>;
15
16impl From<Error> for IoError {
17 fn from(value: Error) -> Self {
18 match value {
19 Error::IO(err) => err,
20 // If other error types are added in the future:
21 // err => IoError::new(std::io::ErrorKind::Other, err),
22 }
23 }
24}