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

init: provide more info when workspace init fails

We classified all errors from initialization as "The target repo
already exists". That's incorrect when the error came from the
backend.
This commit is contained in:
Martin von Zweigbergk 2023-02-03 10:20:03 -08:00 committed by Martin von Zweigbergk
parent e2a5a14463
commit 086398dd55

View file

@ -137,8 +137,21 @@ impl From<BackendError> for CommandError {
}
impl From<WorkspaceInitError> for CommandError {
fn from(_: WorkspaceInitError) -> Self {
user_error("The target repo already exists")
fn from(err: WorkspaceInitError) -> Self {
match err {
WorkspaceInitError::DestinationExists(_) => {
user_error("The target repo already exists")
}
WorkspaceInitError::NonUnicodePath => {
user_error("The target repo path contains non-unicode characters")
}
WorkspaceInitError::CheckOutCommit(err) => CommandError::InternalError(format!(
"Failed to check out the initial commit: {err}"
)),
WorkspaceInitError::Path(err) => {
CommandError::InternalError(format!("Failed to access the repository: {err}"))
}
}
}
}