restorable: Add more detailed information to the panic message

Updates #1427
This commit is contained in:
Hajime Hoshi 2020-12-05 19:56:00 +09:00
parent d4a2433643
commit 410766c984

View File

@ -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 {