forked from lix-project/lix-installer
Improve failure chain on revert (#467)
This commit is contained in:
parent
e3a5ffc8f7
commit
1c18698ee6
|
@ -328,6 +328,12 @@ impl ActionError {
|
|||
pub fn action_tag(&self) -> &ActionTag {
|
||||
&self.action_tag
|
||||
}
|
||||
|
||||
#[cfg(feature = "diagnostics")]
|
||||
pub fn diagnostic(&self) -> String {
|
||||
use crate::diagnostics::ErrorDiagnostic;
|
||||
self.kind.diagnostic()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ActionError {
|
||||
|
@ -572,6 +578,10 @@ impl crate::diagnostics::ErrorDiagnostic for ActionErrorKind {
|
|||
fn diagnostic(&self) -> String {
|
||||
let static_str: &'static str = (self).into();
|
||||
let context = match self {
|
||||
Self::Child(child) => vec![child.diagnostic()],
|
||||
Self::MultipleChildren(children) => {
|
||||
children.iter().map(|child| child.diagnostic()).collect()
|
||||
},
|
||||
Self::Read(path, _)
|
||||
| Self::Open(path, _)
|
||||
| Self::Write(path, _)
|
||||
|
|
|
@ -97,7 +97,11 @@ impl crate::diagnostics::ErrorDiagnostic for NixInstallerError {
|
|||
fn diagnostic(&self) -> String {
|
||||
let static_str: &'static str = (self).into();
|
||||
let context = match self {
|
||||
Self::Action(action_error) => vec![action_error.action_tag().to_string()],
|
||||
Self::Action(action_error) => vec![action_error.diagnostic().to_string()],
|
||||
Self::ActionRevert(action_errors) => action_errors
|
||||
.iter()
|
||||
.map(|action_error| action_error.diagnostic().to_string())
|
||||
.collect(),
|
||||
_ => vec![],
|
||||
};
|
||||
return format!(
|
||||
|
|
Loading…
Reference in a new issue