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-06-14 16:01:42.0 +00:00:00
commit
6ace35b56fab934d3c6b9d80a892ddfcc498b1f8 [patch]
tree
1c946f5072995b937e5cb0ec28b2a97fe375a726
parent
f78de5a1e39c90b8e7d957960cd84178faee9e6e
download
6ace35b56fab934d3c6b9d80a892ddfcc498b1f8.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)
            }
        }
    }