c# - Bad idea to rethrow ex.InnerException? -


Basically, my question is short and sweet: a bad idea following (encapsulating and ex.InnerException rethrowing instead of former ) is

(there's a similar question, but not enough ... I want InnerException reencapsulate, so the stack trace preserved without reflecting internals)

  Public intangible class RpcProvider {public virtual object column (String Name, Parameters Object [] parameter) {MethodInfo mi = This.GetType (). GetMethod (methodName); If (miles throw == null || mi.GetCustomAttributes (typeof (RpcCallAttribute), true) .Length == 0) {new NotImplementedException ( "This method is not provided by the RPC provider."); } And {try {mi.Invoke return (this, parameter); } Catch (target Invocation Akspeshens ex) {new Arpisiakseshn ( "RPC was an error with the call. See Inraksepshn details", ex.InnerException); }}}}  

intact Staktrres bottom and looks fine (well, it calls on how reflection method without internal), if there is a problem? To make sense of the stacktrace below, my inheritance hierarchy is:

 -Oxide.Net.Rpc.RpcProvider | -Oxide.Net.Rpc.XmlRpc | -StartMenuSorterkDesktopMasters (clean to protect the innocent, ie. Me) Oxide.Net.Rpc.XmlRpc.DoRequest in \ projects (Uri rpcConnectionUri, IXPathNavigable request string userAgent) \ OxideLib \ Oxide.Net \ Rpc \ XmlRpc. cs on line StartMenuSorter.DesktopMasters.GetIconInformation at 243 (IEnumerable` 1 symbol) \ projects \ StartMenuSorter \ StartMenuSorter \ DesktopMasters.cs in line Oxide.Net.Rpc.RpcProvider.CallMethod (17, object string methodName [] parameters) \ Projects \ OxideLib \ Oxide.Net \ Rpc \ RpcProvider in CS: line 52 \ projects StartMenuSorter.Program.Main () \ StartMenuSorter \ StartMenuSorter on \ Programkcs: on System.AppDomain.ExecuteAssembly line 36 System.AppDomain._nExecuteAssembly (Assembly assembly, String [] args) (string assemblyFile , Evidence Assembly Security, String [] AGR). System on reading.ThreadHelper.ThreadStart_Context (object state) System.Threading.ExecutionContext.Run (ExecutionContext executionContext, ContextCallback callback on System.Threading.ThreadHelper.ThreadStart, object state) on () 

looks perfectly reasonable: stacktrace, where RpcProvider method includes details of the call, and blood and hides unnecessary reflection gubbins that you're okay

As with all the error handling code, the final consumer will be other developers would do well to ask, "I myself do anything wrong to debug this, you need to have enough detail ? "

There is not so much noise in the way as if the exterior were throwing exceptions, the technique does its job well.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -