pr: throw error on reading from socket

This commit is contained in:
tilakpatidar 2018-12-12 16:48:43 +05:30 committed by Max Semenik
parent 1cf84a7305
commit 8c7cbf65a5

View file

@ -98,9 +98,14 @@ quick_error! {
EncounteredErrors(msg: String) { EncounteredErrors(msg: String) {
display("pr: {0} encountered", msg) display("pr: {0} encountered", msg)
} }
IsDirectory(path: String) { IsDirectory(path: String) {
display("pr: {0}: Is a directory", path) display("pr: {0}: Is a directory", path)
} }
IsSocket(path: String) {
display("pr: cannot open {}, Operation not supported on socket", path)
}
} }
} }
@ -240,8 +245,7 @@ fn open(path: &str) -> Result<Box<Read>, PrError> {
Some(InputType::Directory) => Err(PrError::IsDirectory(path.to_string())), Some(InputType::Directory) => Err(PrError::IsDirectory(path.to_string())),
#[cfg(unix)] #[cfg(unix)]
Some(InputType::Socket) => { Some(InputType::Socket) => {
// TODO Add reading from socket Err(PrError::IsSocket(path.to_string()))
Err(PrError::EncounteredErrors("Reading from socket not supported yet".to_string()))
} }
Some(InputType::StdIn) => { Some(InputType::StdIn) => {
let stdin = stdin(); let stdin = stdin();