Thanks, but in this case the finally Block will be before the Exception Block.
As i said its for a logging purposes or to be more precise it is used for timing
of a codeblock. The actual code is working via a the using statement and looks
more like this
try
{
using(LoggingService.Trace("ActivityID"))
{
DoSomethingTimeConsuming();
}
}
catch(Exception e)
{
// doSomething
throw;
}
My LoggingService.Trace methods return an IDisposable object which does the
timing. It starts timing in its constructor and logs the results in its Dispose
method so i need to know if an exception happened in the Dispose method of that
object.
More ideas?
KH schrieb:
> try
> {
> bool ex = false;
> try
> {
> throw new Exception();
> }
> catch(Exception ex)
> {
> ex = true;
> throw ex;
> }
> finally
> {
> // here i want to know if an exception has been thrown
> if (ex)
> {
> // an exception was thrown
> }
> }
> }
> catch(Exception e)
> {
> // doSomething
> throw;
> }
>
> "Ralf Jansen" wrote:
>
>> For logging purposes i want to determine if the current executing code is
>> running in an ~exceptionhandling context~. I need no details about the exception
>> just if an exception has been thrown and hasn't been handled yet.
>>
>> Following code should make clear what i mean and where i need that info.
>>
>> try
>> {
>> try
>> {
>> throw new Exception();
>> }
>> finally
>> {
>> // here i want to know if an exception has been thrown
>> }
>> }
>> catch(Exception e)
>> {
>> // doSomething
>> throw;
>> }
>>
>>
>> If i put a breakpoint inside the finally block i can inspect the Exception in
>> the debugger through the '$Exception' pseudo variable. Is it possible to get
>> that also in code?
>>
>> Thanks
>>
>> --
>> Ralf Jansen
>>
>> deepinvent Software GmbH - Viersen, Germany - http://www.deepinvent.com
>> Central Email Archiving The Easy Way - http://www.mailstore.com
>>
>>
>>
--
Ralf Jansen
deepinvent Software GmbH - Viersen, Germany -
http://www.deepinvent.com
Central Email Archiving The Easy Way -
http://www.mailstore.com