By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,427 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Console application failing to catch errors

P: n/a
Hi all

I have a console application that runs every night via a scheduled task,
there is a try-catch block in my Main class, whenever an error is caught it
is written to a log file and then emailed to several people. The
application is run using a domain service account, if the program is
successful it emails this result fine.

The problem is, the catch doesn't seem to perform correctly if the program
fails, all I end up with is an entry in the event-log with almost
meaningless error details.

My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Is there any reason why the catch would fail? I'm running out of ideas.

Thanks
Kev
Apr 25 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi Kev,

Perhaps you don't have permission on the log file and the application is
bombing out before the sending mail portion of the program is sent.
--
Regards
Lee Alexander
www.feedghost.com
An RSS Reader for Vista & XP
Synchronize, search, tag and share.

"Mantorok" <no**@none.comwrote in message
news:f0*********@newsfeed.th.ifl.net...
Hi all

I have a console application that runs every night via a scheduled task,
there is a try-catch block in my Main class, whenever an error is caught
it is written to a log file and then emailed to several people. The
application is run using a domain service account, if the program is
successful it emails this result fine.

The problem is, the catch doesn't seem to perform correctly if the program
fails, all I end up with is an entry in the event-log with almost
meaningless error details.

My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Is there any reason why the catch would fail? I'm running out of ideas.

Thanks
Kev

Apr 25 '07 #2

P: n/a
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comwrote:
>My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).
Quite possibly. If you're doing stuff in worker threads you need to
have an exception handler on each worker thread that either logs the
error or communicates the error back to the main thread. If a worker
thread fails due to an exception it won't communicate anything to the
main thread by default, it will simply shut down.
--
http://www.kynosarges.de
Apr 25 '07 #3

P: n/a

"Chris Nahr" <di******@kynosarges.dewrote in message
news:td********************************@4ax.com...
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comwrote:
>>My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Quite possibly. If you're doing stuff in worker threads you need to
have an exception handler on each worker thread that either logs the
error or communicates the error back to the main thread. If a worker
thread fails due to an exception it won't communicate anything to the
main thread by default, it will simply shut down.
I'm pretty sure that's the problem, how do you catch exceptions from
additional threads?

Thanks
Kev
Apr 25 '07 #4

P: n/a
Permissions is ok as the log file is being written to before-hand.

Kev

"Lee Alexander" <lee@feedghost_dot_comwrote in message
news:uo**************@TK2MSFTNGP05.phx.gbl...
Hi Kev,

Perhaps you don't have permission on the log file and the application is
bombing out before the sending mail portion of the program is sent.
--
Regards
Lee Alexander
www.feedghost.com
An RSS Reader for Vista & XP
Synchronize, search, tag and share.

"Mantorok" <no**@none.comwrote in message
news:f0*********@newsfeed.th.ifl.net...
>Hi all

I have a console application that runs every night via a scheduled task,
there is a try-catch block in my Main class, whenever an error is caught
it is written to a log file and then emailed to several people. The
application is run using a domain service account, if the program is
successful it emails this result fine.

The problem is, the catch doesn't seem to perform correctly if the
program fails, all I end up with is an entry in the event-log with almost
meaningless error details.

My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Is there any reason why the catch would fail? I'm running out of ideas.

Thanks
Kev


Apr 25 '07 #5

P: n/a

"Chris Nahr" <di******@kynosarges.dewrote in message
news:td********************************@4ax.com...
On Wed, 25 Apr 2007 10:43:49 +0100, "Mantorok" <no**@none.comwrote:
>>My only thought was that maybe these errors are occurring in my
multi-threaded calls (there are a few).

Quite possibly. If you're doing stuff in worker threads you need to
have an exception handler on each worker thread that either logs the
error or communicates the error back to the main thread. If a worker
thread fails due to an exception it won't communicate anything to the
main thread by default, it will simply shut down.
It is that, I'm now handling my exceptions inside the appropriate threads
and it's working now.

Thanks
Kev
Apr 25 '07 #6

P: n/a
On Wed, 25 Apr 2007 14:54:33 +0100, "Mantorok" <no**@none.comwrote:
>I'm pretty sure that's the problem, how do you catch exceptions from
additional threads?
In the same way as usual, just make sure the exception handler runs on
the thread in question...
--
http://www.kynosarges.de
Apr 25 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.