}).BuildE()
b.Assert(err, qt.IsNotNil)
- b.Assert(err.Error(), qt.Contains, `error calling Width: this method is only available for raster images. To determine if an image is SVG, you can do {{ if eq .MediaType.SubType "svg" }}{{ end }}`)
+ b.Assert(err.Error(), qt.Contains, `error calling Width: resource "/circle.svg" of media type "image/svg+xml" does not support this method: use reflect.IsImageResource, reflect.IsImageResourceProcessable, or reflect.IsImageResourceWithMeta to check if the resource supports this method before calling it`)
}
// Issue 10255.
func (r *resourceAdapter) getImageOps() images.ImageResourceOps {
img, ok := r.target.(images.ImageResourceOps)
if !ok {
- if r.MediaType().SubType == "svg" {
- panic("this method is only available for raster images. To determine if an image is SVG, you can do {{ if eq .MediaType.SubType \"svg\" }}{{ end }}")
- }
- panic("this method is only available for image resources")
+ instructions := "use reflect.IsImageResource, " +
+ "reflect.IsImageResourceProcessable, or " +
+ "reflect.IsImageResourceWithMeta to check if the resource " +
+ "supports this method before calling it"
+ msg := fmt.Sprintf(
+ "resource %q of media type %q does not support this method: %s",
+ r.Name(),
+ r.MediaType(),
+ instructions,
+ )
+ panic(msg)
}
r.init(false, false)
+
return img
}