Search code examples
c++exceptioncatch-all

About the safe use of catch(...) in C++


I was arguing with a colleague about the dangers of using catch(...)

He was pointing me a possible use, rigorously implying that any catch(...) is followed by a trace/log: so as to help determining the origins of some unmanaged exceptions.

I am personnally rather skeptical about that. Do you know about any clear safe use of catch(...)

EDIT: For those interessested in the debate, my colleague has just pointed me to this question on Programmers site.


Solution

  • Exceptions are often overused. Almost always this overuse is accompanied by catch-all statements. This is usually a sign of a bad use and understanding of exceptions. I never recommend it. Sadly, at some (bad) place I worked in, other people enforced this policy.