Skip to content

Commit

Permalink
Don't silent exception when can't extract Icon.
Browse files Browse the repository at this point in the history
Fixes #71
  • Loading branch information
Antoine Aflalo committed Feb 21, 2016
1 parent 8fc9a37 commit 29b6315
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions SoundSwitch/Util/IconExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,28 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;

namespace SoundSwitch.Util
{
public class IconExtractionException : Exception
{
public IconExtractionException()
{
}

public IconExtractionException(string message) : base(message)
{
}

public IconExtractionException(string message, Exception innerException) : base(message, innerException)
{
}

protected IconExtractionException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
public static class IconExtractor
{
/// <summary>
Expand All @@ -27,6 +46,7 @@ public static class IconExtractor
/// <param name="file"></param>
/// <param name="iconIndex"></param>
/// <param name="largeIcon"></param>
/// <exception cref="IconExtractionException">Problem while extracting the icon</exception>
/// <returns></returns>
public static Icon Extract(string file, int iconIndex, bool largeIcon)
{
Expand All @@ -37,9 +57,9 @@ public static Icon Extract(string file, int iconIndex, bool largeIcon)
{
return Icon.FromHandle(largeIcon ? large : small);
}
catch
catch(Exception e)
{
return null;
throw new IconExtractionException($"Can't etract icon from file: {file} / index:{iconIndex}", e);
}
}

Expand Down

0 comments on commit 29b6315

Please sign in to comment.