kibi/
error.rs

1// SPDX-FileCopyrightText: 2020 Ilaï Deutel & Kibi Contributors
2//
3// SPDX-License-Identifier: MIT OR Apache-2.0
4
5//! # Errors
6
7/// Kibi error type.
8#[derive(Debug)]
9pub enum Error {
10    /// Wrapper around `std::io::Error`
11    Io(std::io::Error),
12    /// Wrapper around `std::fmt::Error`
13    Fmt(std::fmt::Error),
14    /// Error returned when the window size obtained through a system call is
15    /// invalid.
16    InvalidWindowSize,
17    /// Error setting or retrieving the cursor position.
18    CursorPosition,
19    /// Too many arguments given to kibi. The attribute corresponds to the total
20    /// number of command line arguments.
21    TooManyArguments(Vec<String>),
22    /// Unrecognized option given as a command line argument.
23    BadOption(String),
24}
25
26impl From<std::io::Error> for Error {
27    /// Convert an IO Error into a Kibi Error.
28    fn from(err: std::io::Error) -> Self { Self::Io(err) }
29}
30
31impl From<std::fmt::Error> for Error {
32    /// Convert an Fmt Error into a Kibi Error.
33    fn from(err: std::fmt::Error) -> Self { Self::Fmt(err) }
34}