mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-18 02:04:19 +00:00
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:
parent
b885dc75f6
commit
977cfd3d4a
2 changed files with 4 additions and 6 deletions
|
@ -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),
|
||||
}
|
||||
|
||||
|
|
|
@ -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}"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue