improve httpServer error handling
This commit is contained in:
parent
1750d9e0e0
commit
61f56f5e80
3
main.go
3
main.go
|
@ -6,6 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -92,7 +93,7 @@ func main() {
|
||||||
mux.HandleFunc("/static", staticHandler)
|
mux.HandleFunc("/static", staticHandler)
|
||||||
mux.HandleFunc("/new", newHandler)
|
mux.HandleFunc("/new", newHandler)
|
||||||
|
|
||||||
if err := httpServer.ListenAndServe(); err == http.ErrServerClosed {
|
if err := httpServer.ListenAndServe(); errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Println("Web server closed")
|
log.Println("Web server closed")
|
||||||
} else {
|
} else {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
|
|
Loading…
Reference in New Issue