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.
@@ -137,9 +137,22 @@ impl From<BackendError> for CommandError {
}
impl From<WorkspaceInitError> for CommandError {
- fn from(_: WorkspaceInitError) -> Self {
+ 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}"))
+ }
+ }
+ }
}
impl From<OpHeadResolutionError<CommandError>> for CommandError {
