use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum AnswerPromptError {
#[error("the input ended before the user answered")]
ClosedInput,
#[error("the prompt was dropped without an answer")]
DroppedRequest,
#[error("the script holds no answer that fits the prompt")]
UnscriptedPrompt,
#[error("failed to use the terminal")]
UnusableTerminal {
source: std::io::Error,
},
}
#[cfg(test)]
mod tests {
#![allow(clippy::missing_panics_doc)]
use super::*;
#[test]
fn display_with_a_closed_input_states_the_condition() {
let error = AnswerPromptError::ClosedInput;
let message = error.to_string();
assert_eq!(message, "the input ended before the user answered");
}
#[test]
fn trait_send() {
fn assert_send<T: Send>() {}
assert_send::<AnswerPromptError>();
}
#[test]
fn trait_sync() {
fn assert_sync<T: Sync>() {}
assert_sync::<AnswerPromptError>();
}
#[test]
fn trait_unpin() {
fn assert_unpin<T: Unpin>() {}
assert_unpin::<AnswerPromptError>();
}
}