Permalink
Browse files

Merge pull request #887 from grumpydev/FaviconFix-886

Fix for #886
  • Loading branch information...
2 parents f62ef50 + 1a92803 commit 588386507865cc471b921bb188814724c1e5985d @grumpydev grumpydev committed Jan 3, 2013
Showing with 19 additions and 6 deletions.
  1. +19 −6 src/Nancy/Bootstrapper/FavIconApplicationStartup.cs
@@ -1,5 +1,6 @@
namespace Nancy.Bootstrapper
{
+ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@@ -76,12 +77,24 @@ private static byte[] LocateIconOnFileSystem()
if (locatedFavIcons.Any())
{
- var image =
- Image.FromFile(locatedFavIcons.First());
-
- var converter = new ImageConverter();
-
- icon = (byte[])converter.ConvertTo(image, typeof(byte[]));
+ try
+ {
+ var image =
+ Image.FromFile(locatedFavIcons.First());
+
+ var converter = new ImageConverter();
+
+ icon = (byte[])converter.ConvertTo(image, typeof(byte[]));
+ }
+ catch (Exception e)
+ {
+ if (!StaticConfiguration.DisableErrorTraces)
+ {
+ throw new InvalidDataException("Unable to load favicon, please check the format is compatible with GDI+", e);
+ }
+
+ return null;
+ }
}
return icon;

0 comments on commit 5883865

Please sign in to comment.