aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-10-11 19:51:13 +0100
committerGitHub <noreply@github.com>2020-10-11 14:51:13 -0400
commit7edf7eb46c4c4d90f3f2a4df0948e94400a129eb (patch)
treef75632c88de94ab9528361974106eaee0200fe8b /modules
parent9066d09c57d3eaddd27c4986900e6afc0885e0c7 (diff)
downloadgitea-7edf7eb46c4c4d90f3f2a4df0948e94400a129eb.tar.gz
gitea-7edf7eb46c4c4d90f3f2a4df0948e94400a129eb.zip
Log the underlying panic in runMigrateTask (#13096)
If there is a panic during runMigrateTask we should capture and log the underlying panic error. This PR ensures that the panic is logged and captured as part of the task message. Fix #13095 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r--modules/task/migrate.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/modules/task/migrate.go b/modules/task/migrate.go
index 9d6c8bf733..d25decaa00 100644
--- a/modules/task/migrate.go
+++ b/modules/task/migrate.go
@@ -5,7 +5,6 @@
package task
import (
- "bytes"
"errors"
"fmt"
"strings"
@@ -39,10 +38,8 @@ func handleCreateError(owner *models.User, err error, name string) error {
func runMigrateTask(t *models.Task) (err error) {
defer func() {
if e := recover(); e != nil {
- var buf bytes.Buffer
- fmt.Fprintf(&buf, "Handler crashed with error: %v", log.Stack(2))
-
- err = errors.New(buf.String())
+ err = fmt.Errorf("PANIC whilst trying to do migrate task: %v\nStacktrace: %v", err, log.Stack(2))
+ log.Critical("PANIC during runMigrateTask[%d] by DoerID[%d] to RepoID[%d] for OwnerID[%d]: %v", t.ID, t.DoerID, t.RepoID, t.OwnerID, err)
}
if err == nil {
@@ -52,14 +49,14 @@ func runMigrateTask(t *models.Task) (err error) {
return
}
- log.Error("FinishMigrateTask failed: %s", err.Error())
+ log.Error("FinishMigrateTask[%d] by DoerID[%d] to RepoID[%d] for OwnerID[%d] failed: %v", t.ID, t.DoerID, t.RepoID, t.OwnerID, err)
}
t.EndTime = timeutil.TimeStampNow()
t.Status = structs.TaskStatusFailed
t.Errors = err.Error()
if err := t.UpdateCols("status", "errors", "end_time"); err != nil {
- log.Error("Task UpdateCols failed: %s", err.Error())
+ log.Error("Task UpdateCols failed: %v", err)
}
if t.Repo != nil {