You are not handling exceptions but call instead a function that very probably throws another one in your
catch
handler.
You should read about exceptions:
try-catch (C# Reference) | Microsoft Docs[
^].
Then check which exceptions might be thrown by the used functions by reading the function references and handle them.
For your case:
BitmapImage Constructor (Uri) (System.Windows.Media.Imaging)[
^] and
Uri Constructor (String, UriKind) (System)[
^].
So it must be something like
bool bSuccess = false;
try
{
bSuccess = true;
}
catch (UriFormatException e)
{
}
catch (FileNotFoundException e)
{
}
if (!bSuccess)
{
}