Better handle transactional errors originating from agent
This commit is contained in:
parent
956f0ce176
commit
4fb2ac7ef8
3 changed files with 10 additions and 5 deletions
|
@ -74,7 +74,8 @@ lazy_static! {
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||
pub enum SyncError {
|
||||
TransactionFailureAgent,
|
||||
TransactionAgentError,
|
||||
TransactionAgentFailure,
|
||||
ParameterAcquisitionFailure,
|
||||
DeserializationFailure,
|
||||
InvalidMagicNumber,
|
||||
|
@ -117,12 +118,15 @@ impl Display for SyncError {
|
|||
Self::InternalError(msg) => write!(fmter, "Internal failure: {msg}"),
|
||||
Self::SignalInterrupt => write!(fmter, "Signal interrupt was triggered."),
|
||||
Self::UnableToLocateKeyrings => write!(fmter, "Unable to locate pacman keyrings."),
|
||||
Self::TransactionAgentError => write!(fmter, "Agent process terminated due to upstream error."),
|
||||
Self::RepoConfError(path, err) => write!(fmter, "'{}': {}", path, err),
|
||||
Self::NothingToDo => write!(fmter, "Nothing to do."),
|
||||
_ => Ok(()),
|
||||
}?;
|
||||
|
||||
if let Self::SignalInterrupt = self {
|
||||
|
||||
if let Self::TransactionFailure(_) = self {
|
||||
Ok(())
|
||||
} else if let Self::SignalInterrupt = self {
|
||||
write!(fmter, "\n{} Transaction aborted.", *ARROW_RED)
|
||||
} else {
|
||||
write!(fmter, "\n{} Transaction failed.", *ARROW_RED)
|
||||
|
|
|
@ -285,7 +285,7 @@ impl<'a> TransactionAggregator<'a> {
|
|||
|
||||
handle.release();
|
||||
return match err.downcast::<SyncError>().map_err(|err| error!(SyncError::from(err)))? {
|
||||
SyncError::TransactionFailureAgent => exit(err.kind().code()),
|
||||
SyncError::TransactionAgentFailure => exit(err.kind().code()),
|
||||
_ => Err(err),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -193,7 +193,8 @@ fn wait_on_agent(mut agent: Child) -> Result<()> {
|
|||
match agent.wait() {
|
||||
Ok(status) => match status.code().unwrap_or(-1) {
|
||||
0 => Ok(()),
|
||||
2 => err!(SyncError::TransactionFailureAgent),
|
||||
1 => err!(SyncError::TransactionAgentError),
|
||||
2 => err!(SyncError::TransactionAgentFailure),
|
||||
3 => err!(SyncError::ParameterAcquisitionFailure),
|
||||
4 => err!(SyncError::DeserializationFailure),
|
||||
5 => err!(SyncError::InvalidMagicNumber),
|
||||
|
|
Loading…
Add table
Reference in a new issue