-
Enhancement
-
Resolution: Fixed
-
P4
-
fx2.0
In our application we are loading a PNG image, and apparently this leads to an error. However, the error is never reported by the Image class - no exception is ever thrown. While debugging I noticed, Image has an isError method, and it returns true, so clearly something went wrong.
I understand that for asynchronously loaded images you cannot throw an exception because the load is dispatched to a different thread, but in our case we are loading the image synchronously like this
Image image = new Image(absoluteUri, width, height, true, true, false);
as you can see, the background loading parameter is false. Hence, I think it is reasonable to expect that the call to new Image will block while loading and then throw an exception, if the loading fails. But it does not - the class simply sets the image error property to true and returns.
I request that the Image class is improved to use a number of exceptions representing each of the ways the loading could go wrong - i.e. ImageNotFoundException, UnsupportedImageFormatException, ...
For synchronous loading I request that this exception is thrown immediately, and for asynchronous loading I request that the exception is stored in the image instance using a new exception property. This will allow me to handle asynchronous errors like this
if(image.isError()) {
Exception e = image.getException()
//log the exception
//tell the user that something went wrong.
}
and allow me to handle synchronous errors like this
try {
Image image = new Image(absoluteUri, width, height, true, true, false);
}
catch(ImageNotFoundException) {
//log the exception
//tell the user that something went wrong.
}
...
I understand that for asynchronously loaded images you cannot throw an exception because the load is dispatched to a different thread, but in our case we are loading the image synchronously like this
Image image = new Image(absoluteUri, width, height, true, true, false);
as you can see, the background loading parameter is false. Hence, I think it is reasonable to expect that the call to new Image will block while loading and then throw an exception, if the loading fails. But it does not - the class simply sets the image error property to true and returns.
I request that the Image class is improved to use a number of exceptions representing each of the ways the loading could go wrong - i.e. ImageNotFoundException, UnsupportedImageFormatException, ...
For synchronous loading I request that this exception is thrown immediately, and for asynchronous loading I request that the exception is stored in the image instance using a new exception property. This will allow me to handle asynchronous errors like this
if(image.isError()) {
Exception e = image.getException()
//log the exception
//tell the user that something went wrong.
}
and allow me to handle synchronous errors like this
try {
Image image = new Image(absoluteUri, width, height, true, true, false);
}
catch(ImageNotFoundException) {
//log the exception
//tell the user that something went wrong.
}
...