mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-19 06:04:26 +00:00
cli: wrap clap::Error within Arc to make CommandError cloneable
This allows us to load workspace by using &Result<T, CommandError>. Even though load_workspace() wouldn't be called more than once, consuming self there is annoying.
This commit is contained in:
parent
1df1603b0b
commit
c3903cb914
@ -58,7 +58,7 @@ use crate::merge_tools::{ConflictResolveError, DiffEditError};
|
|||||||
use crate::templater::TemplateFormatter;
|
use crate::templater::TemplateFormatter;
|
||||||
use crate::ui::{ColorChoice, Ui};
|
use crate::ui::{ColorChoice, Ui};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum CommandError {
|
pub enum CommandError {
|
||||||
UserError {
|
UserError {
|
||||||
message: String,
|
message: String,
|
||||||
@ -68,7 +68,7 @@ pub enum CommandError {
|
|||||||
/// Invalid command line
|
/// Invalid command line
|
||||||
CliError(String),
|
CliError(String),
|
||||||
/// Invalid command line detected by clap
|
/// Invalid command line detected by clap
|
||||||
ClapCliError(clap::Error),
|
ClapCliError(Arc<clap::Error>),
|
||||||
BrokenPipe,
|
BrokenPipe,
|
||||||
InternalError(String),
|
InternalError(String),
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ impl From<glob::PatternError> for CommandError {
|
|||||||
|
|
||||||
impl From<clap::Error> for CommandError {
|
impl From<clap::Error> for CommandError {
|
||||||
fn from(err: clap::Error) -> Self {
|
fn from(err: clap::Error) -> Self {
|
||||||
CommandError::ClapCliError(err)
|
CommandError::ClapCliError(Arc::new(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user