E
Einar Høst
Hi,
I'm doing some logging using the Trace-functionality in .NET, which works
pretty well for me. However, I'm wondering how I should go about logging
data about exceptions that occur. Lately, I've started writing code like:
try
{
...
}
catch (MyException ex)
{
HandleMyException(ex);
}
where HandleMyException looks something like:
void HandleMyException(MyException ex)
{
// Do any clean-up.
// Write to log.
// Swallow or rethrow, depending on the nature of MyException.
}
Similarly, I've started writing code like this:
if (someCondition)
{
ThrowMyException();
}
where ThrowMyException may look something like:
void ThrowMyException()
{
// Write to log.
throw new MyException();
}
Is this good practise? Bad practise? Your wise thoughts are well appreciated

Regards,
Einar
I'm doing some logging using the Trace-functionality in .NET, which works
pretty well for me. However, I'm wondering how I should go about logging
data about exceptions that occur. Lately, I've started writing code like:
try
{
...
}
catch (MyException ex)
{
HandleMyException(ex);
}
where HandleMyException looks something like:
void HandleMyException(MyException ex)
{
// Do any clean-up.
// Write to log.
// Swallow or rethrow, depending on the nature of MyException.
}
Similarly, I've started writing code like this:
if (someCondition)
{
ThrowMyException();
}
where ThrowMyException may look something like:
void ThrowMyException()
{
// Write to log.
throw new MyException();
}
Is this good practise? Bad practise? Your wise thoughts are well appreciated

Regards,
Einar