Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is there really an efficient way to face errors happens sometimes in large business programs in C# or any language?
I think its one of the most difficult thing that a programmer faces errors that appear sometimes. Anyone has any idea please share or any link that I can follow. Thanks.
Posted

If you mean intermittent errors: ones that happen occasionally, but are difficult (or impossible) to reproduce, then there is no one way to find them. They are the hardest problems, and the biggest tests of developers everywhere.

But there are things you can do: look at the error, and try to isolate when it occurs: time of day, day of week, one particular user, one type of data... all of these can be significant.
Look at the data: what is wrong with it? Is there anything that "matches" the input? What should have happened?

And then think. Lots, generally. Try to work out some silly combination of events that might have generated that result. Then try to think of another, no matter how far fetched.

Then try to prove it. If you can duplicate the problem, you've pretty much solved it, if you can't, then you can never be sure. Add logging and see if anything odd shows up. try to get data, basically - because without it you can't do anything.

And remember: http://xkcd.com/583/[^]
Sometimes, you have to put it aside until it happens again - because you can't fix it if you can't reproduce it.
 
Share this answer
 
An efficent way is to work with exceptions and reset the program logic to startup

pseudo code:
C#
while( !Exit )
{
  try
  {
     DoAllTheWork();
     Exit = true;
  }
  catch(...)
  {
     WriteError();
     Exit = AskUserRestart();
  }
}


I like writing a log file in cases of severe errors. I try to provide some useful informations to detect the error reasons, so I can fix it or work on a workaround.

In most times are network errors or some invalid inputs the reason which can get fixed with some lines of code. ;-)
 
Share this answer
 
"for up to a point it is better to let the snags be there"
--Alan Turing
 
Share this answer
 

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