Skip to content

Commit

Permalink
MmException can return function name
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Apr 26, 2023
1 parent 67c5f2a commit cb4e533
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions NAudio.Core/MmException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,22 @@ namespace NAudio
/// </summary>
public class MmException : Exception
{
private MmResult result;
private string function;

/// <summary>
/// Creates a new MmException
/// </summary>
/// <param name="result">The result returned by the Windows API call</param>
/// <param name="function">The name of the Windows API that failed</param>
public MmException(MmResult result, string function)
: base(MmException.ErrorMessage(result, function))
: base(ErrorMessage(result, function))
{
this.result = result;
this.function = function;
Result = result;
Function = function;
}


private static string ErrorMessage(MmResult result, string function)
{
return String.Format("{0} calling {1}", result, function);
return $"{result} calling {function}";
}

/// <summary>
Expand All @@ -42,12 +39,12 @@ public static void Try(MmResult result, string function)
/// <summary>
/// Returns the Windows API result
/// </summary>
public MmResult Result
{
get
{
return result;
}
}
public MmResult Result { get; }

/// <summary>
/// The function being called
/// </summary>
public string Function { get; }

}
}

0 comments on commit cb4e533

Please sign in to comment.