Refactor error handling

This commit is contained in:
waseem-medhat
2025-03-13 15:10:43 +02:00
parent 59115e60e9
commit 2a2dc863bd
4 changed files with 18 additions and 23 deletions

View File

@@ -6,7 +6,10 @@ import (
"net/http"
)
func respondWithError(w http.ResponseWriter, code int, msg string) {
func respondWithError(w http.ResponseWriter, code int, msg string, logErr error) {
if logErr != nil {
log.Println(logErr)
}
if code > 499 {
log.Printf("Responding with 5XX error: %s", msg)
}