This commit is contained in:
2025-07-19 17:54:34 -04:00
commit 18df90b20d
21 changed files with 535 additions and 0 deletions

31
internal/server/errors.go Normal file
View File

@@ -0,0 +1,31 @@
package server
import (
"net/http"
)
func (srv *server) serverError(w http.ResponseWriter, r *http.Request, err error) {
var (
method = r.Method
uri = r.URL.RequestURI()
trace = "" //string(debug.Stack())
)
srv.logger.Error(err.Error(), "method", method, "uri", uri, "trace", trace)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
// Logs server errors silently (without generating http:50x)
func (srv *server) serverErrorSilent(w http.ResponseWriter, r *http.Request, err error) {
var (
method = r.Method
uri = r.URL.RequestURI()
trace = "" //string(debug.Stack())
)
srv.logger.Error(err.Error(), "method", method, "uri", uri, "trace", trace)
}
func (srv *server) clientError(w http.ResponseWriter, status int) {
http.Error(w, http.StatusText(status), status)
}