try
{
result = job->runJob();
}
catch (...)
{
jassertfalse; // Your runJob() method mustn't throw any exceptions!
}
I have a scenario where a dependency I’m using did throw an exception, but the experience of finding out what it was required first removing two catch-alls in JUCE first.
Without the catch-alls, Xcode brings me straight to the exception with the helpful error message explaining how I mis-used the API.
Wouldn’t it be better if these catch-alls existed only in release builds?
It would be safer to remove the whole catch block. Or setting the result to a new error state in the catch.
I don’t like code that runs in debug mode and crashes in release build.
I’m forever having to go and comment out those to find out where I’m throwing an exception that I didn’t intend to. I don’t want to throw an exception in release either, so perhaps it would be better if they didn’t exist at all. Maybe someone from JUCE team can weigh in on the rationale behind these catch-alls, because one assumes they exist for a reason.
Most IDEs let you set ‘exception breakpoints’ which pause execution when an exception is thrown rather than when it is caught. Using exception breakpoints sounds safer than intentionally allowing unhandled exceptions to escape.