diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2019-04-27 19:31:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-27 19:31:07 +0000 |
commit | 18fcc8e699897ceca75920722531b79d909f28fc (patch) | |
tree | 9e855f3afbbe8237a09c9c364832f8c5aa4e57e8 /src/main.rs | |
parent | Describe hashed password feature in README (diff) | |
parent | Combine ContextualError and ContextualErrorKind into one (diff) | |
download | miniserve-18fcc8e699897ceca75920722531b79d909f28fc.tar.gz miniserve-18fcc8e699897ceca75920722531b79d909f28fc.zip |
Merge pull request #88 from KSXGitHub/combine-contextual-error
Combine ContextualError and ContextualErrorKind into one
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 26 |
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(); |