Skip to content

Commit

Permalink
Shorten error message when the file is not a valid image
Browse files Browse the repository at this point in the history
  • Loading branch information
SnipUndercover committed Jan 3, 2025
1 parent 27b4d53 commit 87df87f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,21 @@ private static async ValueTask SearchDirectory(string path, CancellationToken ca
Console.ResetColor();
ConsoleLock.Exit();
}
catch (UnknownImageFormatException)
{
ConsoleLock.Enter();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(
$"[{directoryName}] Image \"{imageName}\" is invalid or corrupted.");
Console.ResetColor();
ConsoleLock.Exit();
}
catch (Exception e)
{
ConsoleLock.Enter();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(
$"[{directoryName}] Image \"{imageName}\" is invalid or corrupted. ({e.GetType().FullName}: {e.Message})");
$"[{directoryName}] Image \"{imageName}\" could not be read. ({e.GetType().FullName}: {e.Message})");
Console.ResetColor();
ConsoleLock.Exit();
}
Expand Down Expand Up @@ -177,12 +186,21 @@ private static async ValueTask SearchFile(string path, CancellationToken cancell
Console.ResetColor();
ConsoleLock.Exit();
}
catch (UnknownImageFormatException)
{
ConsoleLock.Enter();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(
$"[{fileName}] Image \"{imageName}\" is invalid or corrupted.");
Console.ResetColor();
ConsoleLock.Exit();
}
catch (Exception e)
{
ConsoleLock.Enter();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(
$"[{fileName}] Image \"{imageName}\" is invalid or corrupted. ({e.GetType().FullName}: {e.Message})");
$"[{fileName}] Image \"{imageName}\" could not be read. ({e.GetType().FullName}: {e.Message})");
Console.ResetColor();
ConsoleLock.Exit();
}
Expand Down

0 comments on commit 87df87f

Please sign in to comment.