Unverified Commit b0819efa authored by zeripath's avatar zeripath Committed by GitHub
Browse files

Place wrapper around comment as diff to catch panics (#15085) (#15086)


* Place wrapper around comment as diff to prevent panics

* propagate the panic up
Signed-off-by: default avatarAndrew Thornton <art27@cantab.net>
No related merge requests found
Showing with 10 additions and 0 deletions
+10 -0
......@@ -1282,6 +1282,16 @@ func CommentAsDiff(c *models.Comment) (*Diff, error) {
// CommentMustAsDiff executes AsDiff and logs the error instead of returning
func CommentMustAsDiff(c *models.Comment) *Diff {
if c == nil {
return nil
}
defer func() {
if err := recover(); err != nil {
stack := log.Stack(2)
log.Error("PANIC whilst retrieving diff for comment[%d] Error: %v\nStack: %s", c.ID, err, stack)
panic(fmt.Errorf("PANIC whilst retrieving diff for comment[%d] Error: %v\nStack: %s", c.ID, err, stack))
}
}()
diff, err := CommentAsDiff(c)
if err != nil {
log.Warn("CommentMustAsDiff: %v", err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment