Hi,
Is it a code practice for me to have writen the following Class? -
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Collecti ons;
namespace mine
{
static class ExceptionDetail s
{
static public string Details(Excepti on exception)
{
string exceptionString = "";
try
{
int i = 0;
while (exception != null)
{
exceptionString += "*** Exception Level " + i + "
***\n";
exceptionString += "Message: " + exception.Messa ge
+ "\n";
exceptionString += "Source: " + exception.Sourc e +
"\n";
exceptionString += "Target Site: " +
exception.Targe tSite + "\n";
exceptionString += "Stack Trace: " +
exception.Stack Trace + "\n";
exceptionString += "Data: ";
foreach (DictionaryEntr y keyValuePair in
exception.Data)
exceptionString += keyValuePair.Ke y.ToString()
+ ":" + keyValuePair.Va lue.ToString();
exceptionString += "\n***\n\n" ;
exception = exception.Inner Exception;
i++;
}
}
catch{}
return exceptionString ;
}
}
}
I then use it as follows -
try
{
...
}
catch (Exception exception)
{
MessageBox.Show (ExceptionDetai ls.Details(exce ption), "Error.");
}
Thanks,
Barry.
Is it a code practice for me to have writen the following Class? -
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Windows. Forms;
using System.Collecti ons;
namespace mine
{
static class ExceptionDetail s
{
static public string Details(Excepti on exception)
{
string exceptionString = "";
try
{
int i = 0;
while (exception != null)
{
exceptionString += "*** Exception Level " + i + "
***\n";
exceptionString += "Message: " + exception.Messa ge
+ "\n";
exceptionString += "Source: " + exception.Sourc e +
"\n";
exceptionString += "Target Site: " +
exception.Targe tSite + "\n";
exceptionString += "Stack Trace: " +
exception.Stack Trace + "\n";
exceptionString += "Data: ";
foreach (DictionaryEntr y keyValuePair in
exception.Data)
exceptionString += keyValuePair.Ke y.ToString()
+ ":" + keyValuePair.Va lue.ToString();
exceptionString += "\n***\n\n" ;
exception = exception.Inner Exception;
i++;
}
}
catch{}
return exceptionString ;
}
}
}
I then use it as follows -
try
{
...
}
catch (Exception exception)
{
MessageBox.Show (ExceptionDetai ls.Details(exce ption), "Error.");
}
Thanks,
Barry.
Comment