I'm currently loading images in different ways like this:
try { // way 1 } catch { // way 1 didn't work try { // way 2 } catch { // etc. } } I was wondering if there was a cleaner way to do this. Currently it's not a problem but if i add a few more ways it's going to get messy.
Note that the method loading the image is also in a try catch in the same way because it might not be an image.
It's basically trying a bunch of stuff to figure out what it is you dragged into the application.
"why" didn't it work?and handling that is a better design practice rather than letting something throw an error and hoping you cover it with nested catches (especially for something like this). What is happening that you are throwing errors trying to load the image?catchhandlers should only contain code relevant to handling the exception, and nothing more. If you have a need for something like in your example, you should restructure the code.