From e9141f6577579febe698aedd65c2ba06e7175183 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 16 Apr 2018 23:01:59 +0300 Subject: Recover panics in ANSImage.Render() --- lib/ansimage/ansimage.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib') diff --git a/lib/ansimage/ansimage.go b/lib/ansimage/ansimage.go index b117b3d..73425be 100644 --- a/lib/ansimage/ansimage.go +++ b/lib/ansimage/ansimage.go @@ -26,6 +26,7 @@ import ( _ "golang.org/x/image/bmp" // initialize decoder _ "golang.org/x/image/tiff" // initialize decoder _ "golang.org/x/image/webp" // initialize decoder + "maunium.net/go/gomuks/debug" "maunium.net/go/gomuks/ui/messages/tstring" "maunium.net/go/tcell" ) @@ -126,6 +127,11 @@ func (ai *ANSImage) Render() []tstring.TString { ch := make(chan renderData, ai.maxprocs) for n, row := 0, y; (n <= ai.maxprocs) && (2*row+1 < ai.h); n, row = n+1, y+n { go func(row, y int) { + defer func() { + err := recover() + debug.Print("Panic rendering ANSImage:", err) + ch <- renderData{row: row, render: tstring.NewColorTString("ERROR", tcell.ColorRed)} + }() str := make(tstring.TString, ai.w) for x := 0; x < ai.w; x++ { topPixel := ai.pixmap[y][x] -- cgit v1.2.3