Consistently log internal errors

This commit is contained in:
Eli Ribble 2026-02-09 22:43:32 +00:00
parent 13c5529a41
commit b9cf98eee8
No known key found for this signature in database
3 changed files with 16 additions and 10 deletions

View file

@ -2,6 +2,8 @@ package report
import (
"fmt"
"github.com/rs/zerolog/log"
)
type ErrorWithCode struct {
@ -17,6 +19,10 @@ func (e *ErrorWithCode) Error() string {
return e.message
}
func newInternalError(err error, format string, args ...any) *ErrorWithCode {
log.Error().Err(err).Str("format", format).Msg("internal server error")
return newErrorWithCode("internal-error", format, args...)
}
func newErrorWithCode(code string, format string, args ...any) *ErrorWithCode {
if len(args) > 0 {
return &ErrorWithCode{