What you have to do is highly contextual.
If such code was placed in the handler for the "File | Open" option, where you open the image file, then this seems acceptable.
On the other hand, if it was placed deep inside some skins for your application, then this is most likely bad. Firstly, you do not know when this will be done, and if the message field will be appropriate. You do not know how often this will be performed (if it is one of 100 images and then shows 100 messages, this is not good ...). In the fatal case, this can lead to a dead loop, if in any way to show the message window (or reject it by the user) will lead to the repeated execution of this code.
Therefore, if you do not provide context, it is difficult to provide a reasonable and useful answer.
Also note that if you don’t know the details of load_from_file or its guarantee for image_loading_exception content that displays what() user, this is not a good idea. This line is likely to be technical information (or maybe) is not useful and incomprehensible to the user. (On the other hand, if this is just a tool for you or other programmers, then this may be acceptable - context again!)
In addition, if you do not know that image_loading_exception will do this in your what() , you can consider capturing typical cases (missing file, access denied, empty file, damaged file, etc.) and show the highlighted one ("oriented to user ") message, possibly leaving what() as default hidden details or writing them down somewhere.
source share