yazi/yazi-term/src/error.rs
2026-05-25 10:30:04 +08:00

25 lines
752 B
Rust

use std::{num, str};
pub type Result<T, E = ParseError> = std::result::Result<T, E>;
#[derive(Debug, thiserror::Error)]
pub enum ParseError {
/// Malformed or unrecognized byte sequence.
#[error("invalid or unrecognized byte sequence")]
Invalid,
/// Recognised sequence that should not be emitted as an event.
#[error("recognised sequence that should be ignored")]
Ignored,
/// The sequence is not yet complete; more bytes are needed before it can be
/// parsed.
#[error("incomplete sequence; more bytes are needed")]
Incomplete,
}
impl From<str::Utf8Error> for ParseError {
fn from(_: str::Utf8Error) -> Self { Self::Invalid }
}
impl From<num::ParseIntError> for ParseError {
fn from(_: num::ParseIntError) -> Self { Self::Invalid }
}