Skip to content

Commit 1e15d0a

Browse files
committed
Store CargoError inside the ProcessError
1 parent a58f6bb commit 1e15d0a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cargo/util/errors.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub type CargoResult<T> = Result<T, Box<CargoError>>;
2323
pub trait CargoError: Error + Send + 'static {
2424
fn is_human(&self) -> bool { false }
2525
fn cargo_cause(&self) -> Option<&CargoError>{ None }
26+
fn as_error(&self) -> &Error where Self: Sized { self as &Error }
2627
}
2728

2829
impl Error for Box<CargoError> {
@@ -110,13 +111,13 @@ pub struct ProcessError {
110111
pub desc: String,
111112
pub exit: Option<ExitStatus>,
112113
pub output: Option<Output>,
113-
cause: Option<Box<Error + Send>>,
114+
cause: Option<Box<CargoError>>,
114115
}
115116

116117
impl Error for ProcessError {
117118
fn description(&self) -> &str { &self.desc }
118119
fn cause(&self) -> Option<&Error> {
119-
self.cause.as_ref().map(|e| &**e as &Error)
120+
self.cause.as_ref().map(|e| e.as_error())
120121
}
121122
}
122123

@@ -375,7 +376,7 @@ impl CargoError for str::ParseBoolError {}
375376
// Construction helpers
376377

377378
pub fn process_error(msg: &str,
378-
cause: Option<Box<Error + Send>>,
379+
cause: Option<Box<CargoError>>,
379380
status: Option<&ExitStatus>,
380381
output: Option<&Output>) -> ProcessError
381382
{

0 commit comments

Comments
 (0)