mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-12 07:09:36 +08:00
* Place wrapper around comment as diff to prevent panics * propagate the panic up Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
d7a3bcdd70
commit
b0819efaea
@ -1282,6 +1282,16 @@ func CommentAsDiff(c *models.Comment) (*Diff, error) {
|
|||||||
|
|
||||||
// CommentMustAsDiff executes AsDiff and logs the error instead of returning
|
// CommentMustAsDiff executes AsDiff and logs the error instead of returning
|
||||||
func CommentMustAsDiff(c *models.Comment) *Diff {
|
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)
|
diff, err := CommentAsDiff(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("CommentMustAsDiff: %v", err)
|
log.Warn("CommentMustAsDiff: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user