mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
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>
This commit is contained in:
parent
9066d09c57
commit
7edf7eb46c
1 changed files with 4 additions and 7 deletions
|
@ -5,7 +5,6 @@
|
||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -39,10 +38,8 @@ func handleCreateError(owner *models.User, err error, name string) error {
|
||||||
func runMigrateTask(t *models.Task) (err error) {
|
func runMigrateTask(t *models.Task) (err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if e := recover(); e != nil {
|
if e := recover(); e != nil {
|
||||||
var buf bytes.Buffer
|
err = fmt.Errorf("PANIC whilst trying to do migrate task: %v\nStacktrace: %v", err, log.Stack(2))
|
||||||
fmt.Fprintf(&buf, "Handler crashed with error: %v", 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)
|
||||||
|
|
||||||
err = errors.New(buf.String())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -52,14 +49,14 @@ func runMigrateTask(t *models.Task) (err error) {
|
||||||
return
|
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.EndTime = timeutil.TimeStampNow()
|
||||||
t.Status = structs.TaskStatusFailed
|
t.Status = structs.TaskStatusFailed
|
||||||
t.Errors = err.Error()
|
t.Errors = err.Error()
|
||||||
if err := t.UpdateCols("status", "errors", "end_time"); err != nil {
|
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 {
|
if t.Repo != nil {
|
||||||
|
|
Loading…
Reference in a new issue