From 3e0ff1abe1b0020a12e8b764df9bc4fdba4055a8 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 23 Mar 2023 21:26:58 +0900 Subject: [PATCH] ebiten: improve panic messages --- image.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/image.go b/image.go index 3837aef6c..dbb50f386 100644 --- a/image.go +++ b/image.go @@ -441,12 +441,12 @@ func (i *Image) DrawTriangles(vertices []Vertex, indices []uint16, img *Image, o if len(indices)%3 != 0 { panic("ebiten: len(indices) % 3 must be 0") } - for _, idx := range indices { + for i, idx := range indices { if int(idx) >= len(vertices) { - panic(fmt.Sprintf("ebiten: a value in indices must be less than len(vertices) (%d) but was %d", len(vertices), idx)) + panic(fmt.Sprintf("ebiten: indices[%d] must be less than len(vertices) (%d) but was %d", i, len(vertices), idx)) } if idx >= MaxVerticesCount { - panic(fmt.Sprintf("ebiten: a value in indices must be less than MaxVerticesCount %d but was %d", MaxVerticesCount, idx)) + panic(fmt.Sprintf("ebiten: indices[%d] must be less than MaxVerticesCount %d but was %d", i, MaxVerticesCount, idx)) } } @@ -592,12 +592,12 @@ func (i *Image) DrawTrianglesShader(vertices []Vertex, indices []uint16, shader if len(indices)%3 != 0 { panic("ebiten: len(indices) % 3 must be 0") } - for _, idx := range indices { + for i, idx := range indices { if int(idx) >= len(vertices) { - panic(fmt.Sprintf("ebiten: a value in indices must be less than len(vertices) (%d) but was %d", len(vertices), idx)) + panic(fmt.Sprintf("ebiten: indices[%d] must be less than len(vertices) (%d) but was %d", i, len(vertices), idx)) } if idx >= MaxVerticesCount { - panic(fmt.Sprintf("ebiten: a value in indices must be less than MaxVerticesCount %d but was %d", MaxVerticesCount, idx)) + panic(fmt.Sprintf("ebiten: indices[%d] must be less than MaxVerticesCount %d but was %d", i, MaxVerticesCount, idx)) } }