Skip to main content
311 votes
11 answers
197k views

What are the best practices to consider when catching exceptions and re-throwing them? I want to make sure that the Exception object's InnerException and stack trace are preserved. Is there a ...
Seibar's user avatar
  • 70.7k
43 votes
12 answers
8k views

I rethrow an exception with "throw;", but the stacktrace is incorrect: static void Main(string[] args) { try { try { throw new Exception("Test"); //Line 12 } ...
Floyd's user avatar
  • 1,928
113 votes
2 answers
27k views

After searching for some references to figure it out, -unfortunately- I could not find useful -and simple- description about understanding the differences between throws and rethrows. It is kind of ...
Ahmad F's user avatar
  • 31.8k
20 votes
6 answers
7k views

I thought throwing an exception is good practice to let it bubble back up to the UI or somewhere where you log the exception and notify the user about it. Why does resharper say it is redundant? try ...
orandov's user avatar
  • 3,306
16 votes
4 answers
6k views

In my onCreate() I set an UncaughtException handler as follows: Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(...
Eternal Learner's user avatar
10 votes
5 answers
4k views

refering to a lot of documentation on the net, particularly on SO, eg : What is the proper way to re-throw an exception in C#? there should be a difference between "throw e;" and "throw;". But, from :...
Pragmateek's user avatar
  • 13.6k
5 votes
1 answer
2k views

I'm flabbergasted. I always thought that throw by itself in a catch block would throw the exception at hand without altering the stack trace, but that throw ex in a catch block would alter the stack ...
Stephan G's user avatar
  • 3,527
1 vote
1 answer
1k views

I have a class that is derived from another class. I want to be able to catch and re-throw the exception(s) thrown by the derived class's constructor in my derived class's constructor. There seems to ...
fakl's user avatar
  • 127