From 05ea6457bddb93a70589e640df341faa2d25bba9 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Wed, 7 Oct 2020 18:46:27 +0400 Subject: [PATCH] Add throwing right exception when invoking exported plugin method in IPCRouter --- src/Zirconium/Core/Plugins/IPC/IPCRouter.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Zirconium/Core/Plugins/IPC/IPCRouter.cs b/src/Zirconium/Core/Plugins/IPC/IPCRouter.cs index 42c5b13..b665af0 100644 --- a/src/Zirconium/Core/Plugins/IPC/IPCRouter.cs +++ b/src/Zirconium/Core/Plugins/IPC/IPCRouter.cs @@ -1,3 +1,4 @@ +using System.Reflection; using System.Threading.Tasks; using System.Linq; using System; @@ -36,7 +37,15 @@ namespace Zirconium.Core.Plugins.IPC return Task.Factory.StartNew(() => { var method = methodTable[pluginName].Where(x => x.MethodName == methodName).FirstOrDefault(); - var returnValue = method.Method.Invoke(method.Service, new object[] {paramsObject}); + object returnValue = null; + try + { + returnValue = method.Method.Invoke(method.Service, new object[] { paramsObject }); + } + catch (TargetInvocationException e) + { + throw e.InnerException; + } return returnValue; }); } @@ -46,7 +55,14 @@ namespace Zirconium.Core.Plugins.IPC return Task.Factory.StartNew(() => { var method = methodTable[pluginName].Where(x => x.MethodName == methodName).FirstOrDefault(); - method.Method.Invoke(method.Service, paramsObject); + try + { + method.Method.Invoke(method.Service, new object[] { paramsObject }); + } + catch (TargetInvocationException e) + { + throw e.InnerException; + } }); } }