Click here to Skip to main content
15,899,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

How to handle exception properly ?
Let say I am logging exception details to a text file on exception.But while writing exception details if file path not exist/some other exception occur how can I manage it.

How to handle exception if it happens in exception logging method.

Thanks
Posted
Comments
Srinivas Lakkapally 15-Apr-13 7:59am    
How to handle exception if it happens in exception logging method.

Panic.

That's what I generally do.

What I actually do is work on the principle that something has gone seriously wrong if I can't log errors - so the chances are that it's not really my problem - it's a major system fault that I have no control over. So ignore it. Report it to the user so they have a chance to save any data elsewhere if you can, or kill your application. If you can't log an error, then you can't log the fact that there is an error (for example, the disk may be full) so there isn't a lot you can do. If for example the disk is full, then you can't even send yourself an email to let yourself know, because that needs temporary disk space at the email system!
 
Share this answer
 
Comments
fjdiewornncalwe 15-Apr-13 9:40am    
+5. I agree completely. If logging itself has failed then there is a much bigger, more serious issue in play than the application alone. (And why I dislike flat file logging as a default mechanism)
OriginalGriff 15-Apr-13 10:28am    
Agreed - I generally try to a use a DB as at least it is on a different PC (most of the time)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900