Get the entire information of an Exception by recursive looping on the inner Exception property

By [)ia6l0 iii

A simple function to recursively loop thru the inner exception and retrieve the entire information about an exception.

public static string GetFormattedException(Exception ex, bool isRecursive)
        {
            StringBuilder exceptionString = new StringBuilder();

            if (isRecursive)
                exceptionString.AppendFormat(""************ Inner Exception ************{0}"", Environment.NewLine);
            else
                exceptionString.AppendFormat(""*************** Exception ***************{0}"", Environment.NewLine);

            exceptionString.AppendFormat(""Exception Message:{0}{1}{2}"", Environment.NewLine, ex.Message, Environment.NewLine);
            exceptionString.AppendFormat(""Stack Trace:{0}{1}{2}"", Environment.NewLine, ex.StackTrace, Environment.NewLine);
            exceptionString.AppendFormat(""Source:{0}{1}{2}"", Environment.NewLine, ex.Source, Environment.NewLine);

            //recurse into inner exceptions
            if (ex.InnerException != null)
            {
                exceptionString.Append(String.Format(""{0}{1}"", GetFormattedException(ex.InnerException, true), Environment.NewLine));
            }
            return exceptionString.ToString();
         }

Get the entire information of an Exception by recursive looping on the inner Exception property  (236 Views)
Create New Account
Get the entire information of an Exception by recursive looping on the inner Exception property A simple function to recursively loop thru the inner exception and retrieve the entire information about an exception. public static string GetFormattedException(Exception ex, bool isRecursive) { StringBuilder exceptionString = new StringBuilder(); if (isRecursive) exceptionString.AppendFormat(""* ** ** ** ** ** * Inner Exception * ** ** ** ** ** *{0}"", Environment.NewLine); else exceptionString.AppendFormat(""* ** ** ** ** ** ** ** Exception * ** ** ** ** ** ** **{0}"", Environment.NewLine
Helper Function to get the exception details A recursive function to loop through the Inner exceptions and format the required exception details Code Snippet as below: public static string GetExceptionDetails(Exception ex, bool isRecursive) { StringBuilder exceptionString = new StringBuilder(); if (isRecursive) exceptionString AppendFormat(""Inner Exception {0}"", Environment.NewLine); else exceptionString.AppendFormat("" Exception {0}"", Environment.NewLine); exceptionString.AppendFormat(""Exception Message:{0}{1}{2}"", Environment.NewLine, ex.Message, Environment.NewLine Environment.NewLine)); } return exceptionString.ToString(); } Helper Function to get the exception details ( 145 Views ) View [)ia6l0 iii's FAQs Create New
in using stored procedures for all data access with the exception of things that intrinsically require dynamic SQL like searches. I InventoryCount, RemainingInventory FROM RecursiveCTE ORDER BY Product, InventoryDate Using a recursive CTE is not the only way to accomplish the desired thing. In fact, the subquery used below significantly outperforms the recursive CTE example mentioned above. SELECT First.Product, First.InventoryDate, First ROW_NUMBER() OVER (ORDER BY Product, InventoryDate ASC), * FROM Inventory ) First INNER JOIN ( SELECT RowNumber = ROW_NUMBER() OVER (ORDER BY Product, InventoryDate ASC
Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException Hi All, I'm new to Sharepoint and i'm getting this exception Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown, the inner exception is null with this code XElement result = listClient.GetListItems( "VentureAdmin the rootweb instead of the subsite. Create New Account keywords: Exception, of, type, 'Microsoft.SharePoint.SoapServer.SoapServerException description: Hi All, I'm new to Sharepoint and i'm getting this exception Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown, the i
what is exception handling and what is use of exception handling end of post Exception Handling: "EXCEPTION IS A RUNTIME ERROR WHICH ARISES BECAUSE OF ABNORMAL CONDITION INA CODE SEQUENCE. " In C# Exception is a class in the system namespace. An object of an exception is that describe the exceptional conditions occur in a code That means, we are catching an exception, creating an object of it, and then throwing it. C much the same way as Java and C++. Use Of Exception Handling: Trapping and handling of runtime errors is one of Before moving ahead, let's consider a situation where the exception is not handled. We will explain the concept with the C# is shown below try { / / Statement which can cause an exception. } catch (Type x) { / / Statements for handling the exception } finally { / / Any
Now I am using Log4Net open source for logging the exception. Actually what happened, when exception occurs on Data access layer is logged then throw the inner exception to business layer. On business layer, it has own inner exception and inner exception of Data access layer. So there is duplication of logging here 2 times logging of exception , first time on data access layer then on business layer What should i do to stop the double logging of exception Plz help me out. its urgent Note: If question is
Inner exception: Requested registry access is not allowed. I am trying to the error. Any help will be appreciated. Error message Uncaught exception (see the 'inner exception' below) has suspended an instance of service 'NWNatural.BizTalk.EAM last persisted state and may re-throw the same unexpected exception. InstanceId: d3d6e295-50c9-4c35-a583-57e3dd68807e Shape name: ConstructMsgException ShapeId: 1bccf487-7968-443e-ae6f-911e103a44ce Exception thrown from: segment 3, progress 3 Inner exception: Requested registry access is not allowed. Exception type: SecurityException Source: mscorlib Target Site: Void ThrowSecurityException(System.ExceptionResource
Use Exception.ToString() instead of Exception.Message Exception.ToString() contains a detailed description of the Exception with its stack trace. The Message property of the Exception object contains the smaller version of the description. Use Exception.ToString() instead of Exception.Message ( 93 Views ) View [)ia6l0 iii's FAQs Create New Account keywords: Exception, ToString(), Message, Exception.ToString(), detailed, description, , Stack, Trace, description description: Exception.ToString() contains a detailed description of the Exception with its