基本上,我的問題是簡短而親切:在下面的一個壞主意(封裝和重新拋出ex.InnerException而不是前)重新拋出ex.InnerException的壞主意?
(有一個類似的問題here,但不是很......我想reencapsulate的的InnerException,所以堆棧跟蹤不反映內部)
public abstract class RpcProvider
{
public virtual object CallMethod(string methodName, params object[] parameters)
{
MethodInfo mi = this.GetType().GetMethod(methodName);
if (mi == null || mi.GetCustomAttributes(typeof(RpcCallAttribute), true).Length == 0)
{
throw new NotImplementedException("This method is not provided by this RPC provider.");
}
else
{
try
{
return mi.Invoke(this, parameters);
}
catch (TargetInvocationException ex)
{
throw new RpcException("There was an error in the RPC call. See the InnerException for details.", ex.InnerException);
}
}
}
}
下面的堆棧跟蹤似乎完整和精細的(當然,這是SAN的反映如何調用方法的內部)保留,所以有這個的問題所有?對於下面的堆棧跟蹤是有意義的,我的繼承層次是:
-Oxide.Net.Rpc.RpcProvider |-Oxide.Net.Rpc.XmlRpc |-StartMenuSorter.DesktopMasters (sanitised to protect the innocent, ie. me) at Oxide.Net.Rpc.XmlRpc.DoRequest(Uri rpcConnectionUri, IXPathNavigable request, String userAgent) in \Projects\OxideLib\Oxide.Net\Rpc\XmlRpc.cs:line 243 at StartMenuSorter.DesktopMasters.GetIconInformation(IEnumerable`1 icons) in \Projects\StartMenuSorter\StartMenuSorter\DesktopMasters.cs:line 17 at Oxide.Net.Rpc.RpcProvider.CallMethod(String methodName, Object[] parameters) in \Projects\OxideLib\Oxide.Net\Rpc\RpcProvider.cs:line 52 at StartMenuSorter.Program.Main() in \Projects\StartMenuSorter\StartMenuSorter\Program.cs:line 36 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()