Skip to content

Commit

Permalink
Merge pull request #1701 from monty241/monty241-ease-analysis-missing…
Browse files Browse the repository at this point in the history
…-method-exception

Monty241 ease analysis missing method exception
  • Loading branch information
oleg-shilo authored Dec 15, 2024
2 parents 2927171 + a2c60d1 commit 135257a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions Source/src/WixSharp/ManagedProject/ManagedProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,9 @@ static MethodInfo GetHandler(string info)

internal static void InvokeClientHandlers(string eventName, Session session, Exception e)
{
var args = new ExceptionEventArgs { Session = session, Exception = e };
var handlerName = $"WixSharp_{eventName}_Handlers";
ExceptionEventArgs args = new ExceptionEventArgs { Session = session, Exception = e };
string handlerName = $"WixSharp_{eventName}_Handlers";

try
{
string handlersInfo = args.Session.Property(handlerName);
Expand All @@ -836,7 +837,22 @@ internal static void InvokeClientHandlers(string eventName, Session session, Exc
foreach (string item in handlersInfo.Trim().Split('\n').Select(x => x.Trim()))
{
MethodInfo method = GetHandler(item);
method.Call(args);

try
{
method.Call(args);
}
catch (MissingMethodException mex)
{
Exception ex = new Exception
( $"The method for '{item}' was found to be missing when called in the context of the handler '{handlerName}'."
, innerException: mex
);

ex.Data.Add($"{nameof(InvokeClientHandlers)}-item", item);

throw;
}
}
}
}
Expand Down

0 comments on commit 135257a

Please sign in to comment.