From 8732b64aa8eecf73b6b2cc2ed7401503ce44dda6 Mon Sep 17 00:00:00 2001 From: Johannes Batzill Date: Tue, 18 Feb 2025 19:51:52 +0000 Subject: [PATCH] fix: [CODE-3210]: Move error logs on translation layer to verbosity level info (#3451) --- app/api/usererror/translate.go | 4 ++-- app/api/usererror/usererror.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/api/usererror/translate.go b/app/api/usererror/translate.go index 412cb3b89..83608fa84 100644 --- a/app/api/usererror/translate.go +++ b/app/api/usererror/translate.go @@ -46,7 +46,7 @@ func Translate(ctx context.Context, err error) *Error { ) // print original error for debugging purposes - log.Ctx(ctx).Debug().Err(err).Msgf("translating error to user facing error") + log.Ctx(ctx).Info().Err(err).Msgf("translating error to user facing error") // TODO: Improve performance of checking multiple errors with errors.Is @@ -113,7 +113,7 @@ func Translate(ctx context.Context, err error) *Error { case errors.Is(err, codeowners.ErrNotFound): return ErrCodeOwnersNotFound case errors.As(err, &codeOwnersTooLargeError): - return UnprocessableEntityf(codeOwnersTooLargeError.Error()) + return UnprocessableEntity(codeOwnersTooLargeError.Error()) case errors.As(err, &codeOwnersFileParseError): return NewWithPayload( http.StatusUnprocessableEntity, diff --git a/app/api/usererror/usererror.go b/app/api/usererror/usererror.go index 9cdc5c38c..8fbdd854e 100644 --- a/app/api/usererror/usererror.go +++ b/app/api/usererror/usererror.go @@ -145,6 +145,11 @@ func RequestTooLargef(format string, args ...any) *Error { return Newf(http.StatusRequestEntityTooLarge, format, args...) } +// UnprocessableEntity returns a new user facing unprocessable entity error. +func UnprocessableEntity(message string) *Error { + return New(http.StatusUnprocessableEntity, message) +} + // UnprocessableEntityf returns a new user facing unprocessable entity error. func UnprocessableEntityf(format string, args ...any) *Error { return Newf(http.StatusUnprocessableEntity, format, args...)