Permalink
Browse files

Fix for #886

  • Loading branch information...
1 parent 910deca commit 1a9280378e7668b539de6827883e8ace9b617295 @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 1a92803

Please sign in to comment.