Open platform to collect and prioritize feedback
Lintint
Matt Roberts1377cf263184
diff --git a/app/pkg/errors/errors.go b/app/pkg/errors/errors.goindex 4da66fe10..672e367c1 100644--- a/app/pkg/errors/errors.go+++ b/app/pkg/errors/errors.go@@ -18,34 +18,34 @@ func caller(skip int) (string, int) {return file, line}-//New creates a new error+// New creates a new errorfunc New(format string, a ...any) error {file, line := caller(2)text := fmt.Sprintf(format, a...)return fmt.Errorf("%s (%s:%d)", text, file, line)}-//Wrap existing error with additional text+// Wrap existing error with additional textfunc Wrap(err error, format string, a ...any) error {return wrap(err, 0, format, a...)}-//Panicked wraps panick errow with extra details of error+// Panicked wraps panick errow with extra details of errorfunc Panicked(r any) error {err, ok := r.(error)if !ok {err = fmt.Errorf("%v", r)}- err = Wrap(err, identifyPanic())- return Wrap(err, string(debug.Stack()))+ err = Wrap(err, "%s", identifyPanic())+ return Wrap(err, "%s", string(debug.Stack()))}-//Stack add current code location without adding more info+// Stack add current code location without adding more infofunc Stack(err error) error {return wrap(err, 0, "")}-//StackN add code location of N steps before without adding more info+// StackN add code location of N steps before without adding more infofunc StackN(err error, skip int) error {return wrap(err, skip, "")}@@ -103,7 +103,7 @@ func identifyPanic() string {return fmt.Sprintf("pc:%x", pc)}-//Cause returns the original cause of the error stack+// Cause returns the original cause of the error stackfunc Cause(err error) error {casted, ok := err.(*theError)if ok {@@ -112,7 +112,7 @@ func Cause(err error) error {return err}-//Error formats the error trace into human readable+// Error formats the error trace into human readablefunc (err *theError) Error() string {return fmt.Sprintf("Error Trace: \n- %s\n- %v", err.text, err.cause)}diff --git a/app/pkg/i18n/i18n.go b/app/pkg/i18n/i18n.goindex ccf155880..7993ad6ac 100644--- a/app/pkg/i18n/i18n.go+++ b/app/pkg/i18n/i18n.go@@ -125,12 +125,12 @@ func T(ctx context.Context, key string, params ...Params) string {parsedMsg, err := parser.Parse(msg)if err != nil {- panic(errors.Wrap(err, fmt.Sprintf("failed to parse msg '%s'", msg)))+ panic(errors.Wrap(err, "failed to parse msg %s", msg))}str, err := parsedMsg.FormatMap(params[0])if err != nil {- panic(errors.Wrap(err, fmt.Sprintf("failed to format msg '%s' with params '%v'", msg, params[0])))+ panic(errors.Wrap(err, "failed to format msg '%s' with params '%v'", msg, params[0]))}return strdiff --git a/app/tasks/new_comment.go b/app/tasks/new_comment.goindex 6a6f058fa..a44399a4f 100644--- a/app/tasks/new_comment.go+++ b/app/tasks/new_comment.go@@ -206,11 +206,10 @@ func NotifyAboutUpdatedComment(content string, post *entity.Post) worker.Task {})}-func sendEmailNotifications(c *worker.Context, post *entity.Post, to []dto.Recipient, comment string, event enum.NotificationEvent) error {-+func sendEmailNotifications(c *worker.Context, post *entity.Post, to []dto.Recipient, comment string, event enum.NotificationEvent) {// Short circuit if there is no one to notifyif len(to) == 0 {- return nil+ return}author := c.User()@@ -240,7 +239,4 @@ func sendEmailNotifications(c *worker.Context, post *entity.Post, to []dto.RecipTemplateName: "new_comment",Props: mailProps,})-- return nil-}