better error messages %T -> (%T)
This commit is contained in:
parent
7f38aac901
commit
a1e7f9bf04
5
batch.go
5
batch.go
|
@ -73,6 +73,9 @@ func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
|
||||||
|
|
||||||
// MakePicture returns a specialized copy of the provided Picture that draws onto this Batch.
|
// MakePicture returns a specialized copy of the provided Picture that draws onto this Batch.
|
||||||
func (b *Batch) MakePicture(p Picture) TargetPicture {
|
func (b *Batch) MakePicture(p Picture) TargetPicture {
|
||||||
|
if p.Original() != b.cont.Picture.Original() {
|
||||||
|
panic(fmt.Errorf("(%T).MakePicture: Picture is not a slice of Batch's Picture", b))
|
||||||
|
}
|
||||||
bp := &batchPicture{
|
bp := &batchPicture{
|
||||||
Picture: p,
|
Picture: p,
|
||||||
dst: b,
|
dst: b,
|
||||||
|
@ -134,7 +137,7 @@ func (bp *batchPicture) Original() Picture {
|
||||||
func (bp *batchPicture) Draw(t TargetTriangles) {
|
func (bp *batchPicture) Draw(t TargetTriangles) {
|
||||||
bt := t.(*batchTriangles)
|
bt := t.(*batchTriangles)
|
||||||
if bp.dst != bt.dst {
|
if bp.dst != bt.dst {
|
||||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Batch", bp))
|
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Batch", bp))
|
||||||
}
|
}
|
||||||
bt.draw(bp)
|
bt.draw(bp)
|
||||||
}
|
}
|
||||||
|
|
2
data.go
2
data.go
|
@ -89,7 +89,7 @@ func (td *TrianglesData) updateData(t Triangles) {
|
||||||
// TrianglesPosition, TrianglesColor and TrianglesTexture are supported.
|
// TrianglesPosition, TrianglesColor and TrianglesTexture are supported.
|
||||||
func (td *TrianglesData) Update(t Triangles) {
|
func (td *TrianglesData) Update(t Triangles) {
|
||||||
if td.Len() != t.Len() {
|
if td.Len() != t.Len() {
|
||||||
panic(fmt.Errorf("%T.Update: invalid triangles length", td))
|
panic(fmt.Errorf("(%T).Update: invalid triangles length", td))
|
||||||
}
|
}
|
||||||
td.updateData(t)
|
td.updateData(t)
|
||||||
}
|
}
|
||||||
|
|
|
@ -402,7 +402,7 @@ func (cp *canvasPicture) Color(at pixel.Vec) pixel.NRGBA {
|
||||||
func (cp *canvasPicture) Draw(t pixel.TargetTriangles) {
|
func (cp *canvasPicture) Draw(t pixel.TargetTriangles) {
|
||||||
ct := t.(*canvasTriangles)
|
ct := t.(*canvasTriangles)
|
||||||
if cp.dst != ct.dst {
|
if cp.dst != ct.dst {
|
||||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", cp))
|
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Canvas", cp))
|
||||||
}
|
}
|
||||||
ct.draw(cp.tex, cp.borders, cp.bounds)
|
ct.draw(cp.tex, cp.borders, cp.bounds)
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ func (ccp *canvasCanvasPicture) Color(at pixel.Vec) pixel.NRGBA {
|
||||||
func (ccp *canvasCanvasPicture) Draw(t pixel.TargetTriangles) {
|
func (ccp *canvasCanvasPicture) Draw(t pixel.TargetTriangles) {
|
||||||
ct := t.(*canvasTriangles)
|
ct := t.(*canvasTriangles)
|
||||||
if ccp.dst != ct.dst {
|
if ccp.dst != ct.dst {
|
||||||
panic(fmt.Errorf("%T.Draw: TargetTriangles generated by different Canvas", ccp))
|
panic(fmt.Errorf("(%T).Draw: TargetTriangles generated by different Canvas", ccp))
|
||||||
}
|
}
|
||||||
ct.draw(ccp.src.orig.f.Texture(), ccp.src.orig.borders, ccp.bounds)
|
ct.draw(ccp.src.orig.f.Texture(), ccp.src.orig.borders, ccp.bounds)
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ func (gt *GLTriangles) submitData() {
|
||||||
// The two Triangles (gt and t) must be of the same len.
|
// The two Triangles (gt and t) must be of the same len.
|
||||||
func (gt *GLTriangles) Update(t pixel.Triangles) {
|
func (gt *GLTriangles) Update(t pixel.Triangles) {
|
||||||
if gt.Len() != t.Len() {
|
if gt.Len() != t.Len() {
|
||||||
panic(fmt.Errorf("%T.Update: invalid triangles len", gt))
|
panic(fmt.Errorf("(%T).Update: invalid triangles len", gt))
|
||||||
}
|
}
|
||||||
gt.updateData(t)
|
gt.updateData(t)
|
||||||
gt.submitData()
|
gt.submitData()
|
||||||
|
|
Loading…
Reference in New Issue