ok/jj
1
0
Fork 0
forked from mirrors/jj

repo_path: make FsPathParseError displayable by itself

So it can be easily embedded in other error types such as RevsetError.
This commit is contained in:
Yuya Nishihara 2022-10-23 13:39:38 +09:00
parent b885dc75f6
commit 977cfd3d4a
2 changed files with 4 additions and 6 deletions

View file

@ -16,6 +16,7 @@ use std::fmt::{Debug, Error, Formatter};
use std::path::{Component, Path, PathBuf};
use itertools::Itertools;
use thiserror::Error;
use crate::file_util;
@ -178,8 +179,9 @@ impl RepoPathJoin<RepoPathComponent> for RepoPath {
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, Error, PartialEq)]
pub enum FsPathParseError {
#[error(r#"Path "{0}" is not in the repo"#)]
InputNotInRepo(String),
}

View file

@ -168,11 +168,7 @@ impl From<RevsetError> for CommandError {
impl From<FsPathParseError> for CommandError {
fn from(err: FsPathParseError) -> Self {
match err {
FsPathParseError::InputNotInRepo(input) => {
CommandError::UserError(format!("Path \"{input}\" is not in the repo"))
}
}
CommandError::UserError(format!("{err}"))
}
}