-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch replaces error-chain with the current version of thiserror. There's nothing done more, so no cleanup of .expect() or .unwrap() calls, just a plain conversion from one crate to another. Signed-off-by: Matthias Beyer <[email protected]>
- Loading branch information
1 parent
9b3884e
commit 0cddb83
Showing
5 changed files
with
115 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
use std::time; | ||
|
||
error_chain::error_chain! { | ||
errors { | ||
EOF(expected:String, got:String, exit_code:Option<String>) { | ||
description("End of filestream (usually stdout) occurred, most probably\ | ||
because the process terminated") | ||
display("EOF (End of File): Expected {} but got EOF after reading \"{}\", \ | ||
process terminated with {:?}", expected, got, | ||
exit_code.as_ref() | ||
.unwrap_or(& "unknown".to_string())) | ||
} | ||
BrokenPipe { | ||
description("The pipe to the process is broken. Most probably because\ | ||
the process died.") | ||
display("PipeError") | ||
} | ||
Timeout(expected:String, got:String, timeout:time::Duration) { | ||
description("The process didn't end within the given timeout") | ||
display("Timeout Error: Expected {} but got \"{}\" (after waiting {} ms)", | ||
expected, got, (timeout.as_secs() * 1000) as u32 | ||
+ timeout.subsec_millis()) | ||
} | ||
EmptyProgramName { | ||
description("The provided program name is empty.") | ||
display("EmptyProgramName") | ||
} | ||
} | ||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("EOF (End of File): Expected {} but got EOF after reading \"{}\" process terminated with {:?}", .expected, .got, .exit_code.as_ref().unwrap_or(&"unknown".to_string()))] | ||
EOF { | ||
expected: String, | ||
got: String, | ||
exit_code: Option<String>, | ||
}, | ||
|
||
#[error("PipeError")] | ||
BrokenPipe, | ||
|
||
#[error("Timeout Error: Expected {} but got \"{}\" (after waiting {} ms)", .expected, .got, (.timeout.as_secs() * 1000) as u32 + .timeout.subsec_millis())] | ||
Timeout { | ||
expected: String, | ||
got: String, | ||
timeout: time::Duration, | ||
}, | ||
|
||
#[error("The provided program name is empty.")] | ||
EmptyProgramName, | ||
|
||
#[error(transparent)] | ||
Nix(#[from] nix::Error), | ||
|
||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
|
||
#[error("Did not understand Ctrl-{}", .0)] | ||
SendContolError(char), | ||
|
||
#[error("Failed to send via MPSC channel")] | ||
MpscSendError, | ||
|
||
#[error(transparent)] | ||
Regex(#[from] regex::Error), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.