Skip to content

Commit f28b388

Browse files
committed
Handle Errors converting mime data tp images
1 parent cad43ad commit f28b388

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

PasteIntoFile/ClipboardContents.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,12 @@ public static ClipboardContents FromClipboard() {
798798
var formats = extensions.SelectMany(ext => MimeForImageExtension(ext).Concat(new[] { ext }));
799799
foreach (var format in formats) { // case insensitive
800800
if (Clipboard.ContainsData(format) && Clipboard.GetData(format) is MemoryStream stream)
801-
if (Image.FromStream(stream) is Image img)
802-
images.Add(format, img);
801+
try {
802+
if (Image.FromStream(stream) is Image img)
803+
images.Add(format, img);
804+
} catch (Exception e) {
805+
Console.WriteLine(e);
806+
}
803807
}
804808

805809
// Generic image from encoded data uri

0 commit comments

Comments
 (0)