Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
fix: improve error reporting when port is in use
Browse files Browse the repository at this point in the history
Before this change, when we could not start listening on webserver's TCP
port, the binary produced by GoReleaser would abort with no meaningful
error report:

    ```
    ❯ ./build/saturn/l2node-darwin-arm64/saturn-l2
    [1]    16654 killed     ./build/saturn/l2node-darwin-arm64/saturn-l2
    ```

In this commit, I am reworking error handling to print the error to
stderr and exit the process with a non-zero exit code via `os.Exit`.

Signed-off-by: Miroslav Bajtoš <saturn@bajtos.net>
  • Loading branch information
bajtos committed Jul 13, 2022
1 parent 615060d commit 7239c2e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func main() {

nl, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
panic(err)
fmt.Fprintf(os.Stderr, "Cannot start the webserver: %s\n", err.Error())
os.Exit(4)
}

go func() {
Expand Down

0 comments on commit 7239c2e

Please sign in to comment.