Skip to content

Commit

Permalink
revset: add two new error variants to support extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
torquestomp committed Apr 18, 2024
1 parent 844a8ad commit f319e58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cli/src/command_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ impl From<RevsetResolutionError> for CommandError {
| RevsetResolutionError::WorkspaceMissingWorkingCopy { .. }
| RevsetResolutionError::AmbiguousCommitIdPrefix(_)
| RevsetResolutionError::AmbiguousChangeIdPrefix(_)
| RevsetResolutionError::StoreError(_) => None,
| RevsetResolutionError::AmbiguousSymbol(_)
| RevsetResolutionError::StoreError(_)
| RevsetResolutionError::Other(_) => None,
};
let mut cmd_err = user_error(err);
cmd_err.extend_hints(hint);
Expand Down
8 changes: 7 additions & 1 deletion lib/src/revset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ pub enum RevsetResolutionError {
AmbiguousCommitIdPrefix(String),
#[error("Change ID prefix \"{0}\" is ambiguous")]
AmbiguousChangeIdPrefix(String),
#[error("Symbol \"{0}\" is ambiguous")]
AmbiguousSymbol(String),
#[error("Unexpected error from store")]
StoreError(#[source] BackendError),
#[error(transparent)]
Other(#[from] Box<dyn std::error::Error + Send + Sync>),
}

/// Error occurred during revset evaluation.
Expand Down Expand Up @@ -2278,7 +2282,9 @@ fn resolve_symbols(
| RevsetResolutionError::EmptyString
| RevsetResolutionError::AmbiguousCommitIdPrefix(_)
| RevsetResolutionError::AmbiguousChangeIdPrefix(_)
| RevsetResolutionError::StoreError(_) => Err(err),
| RevsetResolutionError::AmbiguousSymbol(_)
| RevsetResolutionError::StoreError(_)
| RevsetResolutionError::Other(_) => Err(err),
})
.map(Some) // Always rewrite subtree
}
Expand Down

0 comments on commit f319e58

Please sign in to comment.