gogmagog/routes/errors.go
Deepak 3f13118312
All checks were successful
gitea-deepak/gogmagog/pipeline/head This commit looks good
Adds more error handling and sets plan date
2021-01-09 16:11:43 -06:00

28 lines
696 B
Go

package routes
import (
"log"
"net/http"
)
func serverError(w http.ResponseWriter, err error) {
code := http.StatusInternalServerError
log.Printf("received error: {%v}", err)
http.Error(w, http.StatusText(code), code)
}
func badRequestError(w http.ResponseWriter, err error) {
code := http.StatusBadRequest
log.Printf("received error: {%v}", err)
http.Error(w, http.StatusText(code), code)
}
func methodNotAllowedHandler(w http.ResponseWriter, r *http.Request) {
code := http.StatusMethodNotAllowed
http.Error(w, http.StatusText(code), code)
}
func notFoundHandler(w http.ResponseWriter, r *http.Request) {
code := http.StatusNotFound
http.Error(w, http.StatusText(code), code)
}