From af7e229a597c49add4855923aa87c92de82209b0 Mon Sep 17 00:00:00 2001 From: hamki Date: Thu, 27 Nov 2025 12:32:44 +0800 Subject: [PATCH 1/2] Fix error handling in mailer and wiki services - Updated error message in `incoming.go` to remove unnecessary wrapping of the error. - Corrected typo in error message in `wiki.go` for clarity. --- services/mailer/incoming/incoming.go | 2 +- services/wiki/wiki.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/mailer/incoming/incoming.go b/services/mailer/incoming/incoming.go index eade0cf271bf8..1d2089acb2c42 100644 --- a/services/mailer/incoming/incoming.go +++ b/services/mailer/incoming/incoming.go @@ -221,7 +221,7 @@ loop: err := func() error { r := msg.GetBody(section) if r == nil { - return fmt.Errorf("could not get body from message: %w", err) + return fmt.Errorf("could not get body from message") } env, err := enmime.ReadEnvelope(r) diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go index a9dc7269829f3..6a57a9a63e7d8 100644 --- a/services/wiki/wiki.go +++ b/services/wiki/wiki.go @@ -135,7 +135,7 @@ func updateWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model if hasDefaultBranch { if err := gitRepo.ReadTreeToIndex("HEAD"); err != nil { log.Error("Unable to read HEAD tree to index in: %s %v", basePath, err) - return fmt.Errorf("fnable to read HEAD tree to index in: %s %w", basePath, err) + return fmt.Errorf("unable to read HEAD tree to index in: %s %w", basePath, err) } } From cfa44d60d759b608dfb262f45588acdfda217a6a Mon Sep 17 00:00:00 2001 From: hamki Date: Thu, 27 Nov 2025 15:14:39 +0800 Subject: [PATCH 2/2] Refactor error handling in incoming mailer - Replaced fmt.Errorf with errors.New for improved error handling in incoming.go. - Updated error message to enhance clarity. --- services/mailer/incoming/incoming.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/mailer/incoming/incoming.go b/services/mailer/incoming/incoming.go index 1d2089acb2c42..1efaa845b811d 100644 --- a/services/mailer/incoming/incoming.go +++ b/services/mailer/incoming/incoming.go @@ -6,6 +6,7 @@ package incoming import ( "context" "crypto/tls" + "errors" "fmt" net_mail "net/mail" "regexp" @@ -221,7 +222,7 @@ loop: err := func() error { r := msg.GetBody(section) if r == nil { - return fmt.Errorf("could not get body from message") + return errors.New("could not get body from message") } env, err := enmime.ReadEnvelope(r)