You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
956 B
56 lines
956 B
//! Argument related errors
|
|
use super::*;
|
|
use std::{
|
|
error,
|
|
fmt,
|
|
};
|
|
|
|
#[derive(Debug)]
|
|
#[non_exhaustive]
|
|
pub enum ParseErrorKind
|
|
{
|
|
ExpectedArg(String),
|
|
UnknownOption(char),
|
|
UnknownOptionFor(char, char),
|
|
CannotCombine(char, char),
|
|
BadTail(char, String),
|
|
NotUnique(char),
|
|
}
|
|
|
|
impl From<(String, ParseErrorKind)> for Error
|
|
{
|
|
#[inline] fn from((froms, fromk): (String, ParseErrorKind)) -> Self
|
|
{
|
|
Self::Parse(froms, fromk)
|
|
}
|
|
}
|
|
|
|
|
|
#[derive(Debug)]
|
|
#[non_exhaustive]
|
|
pub enum Error {
|
|
Parse(String, ParseErrorKind),
|
|
|
|
Unknown,
|
|
AtomInternal,
|
|
}
|
|
impl error::Error for Error{}
|
|
impl fmt::Display for Error
|
|
{
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
|
|
{
|
|
match self {
|
|
_ => write!(f, "unknown error"),
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
impl<T> From<tokio::sync::mpsc::error::SendError<T>> for Error
|
|
{
|
|
#[inline] fn from(_: tokio::sync::mpsc::error::SendError<T>) -> Self
|
|
{
|
|
Self::AtomInternal
|
|
}
|
|
}
|