aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorkhai96_ <hvksmr1996@gmail.com>2019-04-27 06:56:45 +0000
committerkhai96_ <hvksmr1996@gmail.com>2019-04-27 06:56:45 +0000
commit58eee2f329859c33008a5b8b5af53189b2b4ab4a (patch)
tree2aa131c47eec383ca9dea843c735a05688fd7421 /src/main.rs
parentMerge pull request #84 from KSXGitHub/patch-1 (diff)
downloadminiserve-58eee2f329859c33008a5b8b5af53189b2b4ab4a.tar.gz
miniserve-58eee2f329859c33008a5b8b5af53189b2b4ab4a.zip
Combine ContextualError and ContextualErrorKind into one
Diffstat (limited to '')
-rw-r--r--src/main.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index bc8f3f0..c1bb0aa 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,7 +19,7 @@ mod listing;
mod renderer;
mod themes;
-use crate::errors::{ContextualError, ContextualErrorKind};
+use crate::errors::{ContextualError};
#[derive(Clone)]
/// Configuration of the Miniserve application
@@ -84,10 +84,10 @@ fn run() -> Result<(), ContextualError> {
.path
.symlink_metadata()
.map_err(|e| {
- ContextualError::new(ContextualErrorKind::IOError(
+ ContextualError::IOError(
"Failed to retrieve symlink's metadata".to_string(),
e,
- ))
+ )
})?
.file_type()
.is_symlink()
@@ -117,10 +117,10 @@ fn run() -> Result<(), ContextualError> {
.collect::<Vec<String>>();
let canon_path = miniserve_config.path.canonicalize().map_err(|e| {
- ContextualError::new(ContextualErrorKind::IOError(
+ ContextualError::IOError(
"Failed to resolve path to be served".to_string(),
e,
- ))
+ )
})?;
let path_string = canon_path.to_string_lossy();
@@ -136,18 +136,18 @@ fn run() -> Result<(), ContextualError> {
);
print!("Starting server in ");
io::stdout().flush().map_err(|e| {
- ContextualError::new(ContextualErrorKind::IOError(
+ ContextualError::IOError(
"Failed to write data".to_string(),
e,
- ))
+ )
})?;
for c in "3… 2… 1… \n".chars() {
print!("{}", c);
io::stdout().flush().map_err(|e| {
- ContextualError::new(ContextualErrorKind::IOError(
+ ContextualError::IOError(
"Failed to write data".to_string(),
e,
- ))
+ )
})?;
thread::sleep(Duration::from_millis(500));
}
@@ -196,10 +196,10 @@ fn run() -> Result<(), ContextualError> {
// Note that this should never fail, since CLI parsing succeeded
// This means the format of each IP address is valid, and so is the port
// Valid IpAddr + valid port == valid SocketAddr
- return Err(ContextualError::new(ContextualErrorKind::ParseError(
+ return Err(ContextualError::ParseError(
"string as socket address".to_string(),
e.to_string(),
- )));
+ ));
}
};
@@ -211,10 +211,10 @@ fn run() -> Result<(), ContextualError> {
})
.bind(socket_addresses.as_slice())
.map_err(|e| {
- ContextualError::new(ContextualErrorKind::IOError(
+ ContextualError::IOError(
"Failed to bind server".to_string(),
e,
- ))
+ )
})?
.shutdown_timeout(0)
.start();