mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-08 21:48:08 +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 std::path::{Component, Path, PathBuf};
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::file_util;
|
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 {
|
pub enum FsPathParseError {
|
||||||
|
#[error(r#"Path "{0}" is not in the repo"#)]
|
||||||
InputNotInRepo(String),
|
InputNotInRepo(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,11 +168,7 @@ impl From<RevsetError> for CommandError {
|
||||||
|
|
||||||
impl From<FsPathParseError> for CommandError {
|
impl From<FsPathParseError> for CommandError {
|
||||||
fn from(err: FsPathParseError) -> Self {
|
fn from(err: FsPathParseError) -> Self {
|
||||||
match err {
|
CommandError::UserError(format!("{err}"))
|
||||||
FsPathParseError::InputNotInRepo(input) => {
|
|
||||||
CommandError::UserError(format!("Path \"{input}\" is not in the repo"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue