如何打印为什么图像加载失败的错误信息? [英] How to print error message of why image failed to load?
本文介绍了如何打印为什么图像加载失败的错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以从图像加载失败中获得任何错误信息吗?我有以下内容:
Can we get any error information from an image load failure? I have the following:
Image image = new Image(imagePath);
image.addErrorHandler(new ErrorHandler() {
Override
public void onError(ErrorEvent event) {
// what can we print here from 'event'?
}
});
我有一段时间无法加载的图像,我只是试着让event.toString ()方法打印自己,但我只是得到这样的东西:
I have an image that fails to load once in awhile, and I just tried letting the event.toString() method print itself, but I just get something like:
println("Error!: " + event);
// "Error: An event type"
所以我不确定为什么图片加载失败,
so I'm not sure why the image fails to load,
谢谢
Thank you
推荐答案
目前您可以不知道是什么原因导致了错误,但是你可以知道是什么类型的错误导致了错误,它给出了一个很好的想法,可能会出错。
Currently you can't know what caused the error, but you can know what type of error caused it and it gives fairly a good idea on what might have gone wrong
event.getAssociatedType();
OR
event.getType();
这篇关于如何打印为什么图像加载失败的错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文