I have a class the implements A which will run a certain method of class B. There is a requirement that this A should never crash when running this operation (which is not possible, right?).
To reduce the chance of crashing I'm catching Throwable around the operation, like so:
public void method(B b) { try { b.operation } catch(Throwable e) { //Log e //Clean up stuff } } My questions are:
- Would this actually help in reducing crashes caused by any thrown
Error? - Is it a good idea to ever catch an
Error?
ExecutorServicewill not stop running if your code throws an exception, it's just theRunnablewill stop and not be rescheduled. Other than that - Do you really need this particular module to continue working even if the rest of the app just went haywire?