From 410766c984a0b15c18bb459c9a91ecf2fb83361c Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 5 Dec 2020 19:56:00 +0900 Subject: [PATCH] restorable: Add more detailed information to the panic message Updates #1427 --- internal/restorable/rect.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/restorable/rect.go b/internal/restorable/rect.go index b3f54c777..03746b850 100644 --- a/internal/restorable/rect.go +++ b/internal/restorable/rect.go @@ -30,7 +30,11 @@ type rectToPixels struct { func (rtp *rectToPixels) addOrReplace(pixels []byte, x, y, width, height int) { if len(pixels) != 4*width*height { - panic(fmt.Sprintf("restorable: len(pixels) must be %d but %d", 4*width*height, len(pixels))) + msg := fmt.Sprintf("restorable: len(pixels) must be 4*%d*%d = %d but %d", width, height, 4*width*height, len(pixels)) + if pixels == nil { + msg += " (nil)" + } + panic(msg) } if rtp.m == nil {