index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2021-05-27 20:24:57.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2021-05-27 20:24:57.0 +00:00:00
commit
bf87d7f873c7615c170787689f6af42c06be415f [patch]
tree
3663ac87cbbadd1fc5acc379cf4ffb04d2a83f12
parent
43cd2c81b1ebe7076b0386bec067b95d62d81ed6
download
bf87d7f873c7615c170787689f6af42c06be415f.tar.gz

refactor: improve error messages for address binding errors

it improves the error message during server launching instead of just
panic when address binding errors occur

Diff

 src/server.rs | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/server.rs b/src/server.rs
index 2db456b..d9d94af 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -42,7 +42,10 @@ pub fn run(opts: Options) {
                listening,
                server_type: "HTTPS".to_string(),
            }),
            Err(err) => panic!("{:?}", err),
            Err(err) => {
                error!("Error binding to address {} for https: {}", addr, err);
                std::process::exit(1)
            }
        }

        // Launch redirect HTTP server (if requested)
@@ -59,7 +62,13 @@ pub fn run(opts: Options) {
                    listening,
                    server_type: "Redirect HTTP".to_string(),
                }),
                Err(err) => panic!("{:?}", err),
                Err(err) => {
                    error!(
                        "Error binding to address {} for http redirection: {}",
                        addr, err
                    );
                    std::process::exit(1)
                }
            }
        }
    } else {
@@ -69,7 +78,10 @@ pub fn run(opts: Options) {
                listening,
                server_type: "HTTP".to_string(),
            }),
            Err(err) => panic!("{:?}", err),
            Err(err) => {
                error!("Error binding to address {} for http: {}", addr, err);
                std::process::exit(1)
            }
        }
    }