kframework/k — pull request #395 by dwightguth (2014-04-21 15:09:52+00:00)
Title: refactor the way the application exits and exceptions are caught

I am still in the process of testing this, so it may not pass all tests yet. When it is ready for review, I will let you know.

To summarize the change:

* The new and only way to terminate the application prematurely is to call GlobalSettings.kem.register. This throws a KEMException which is caught by org.kframework.main.Main.
* org.kframework.main.Main is the only class allowed to call System.exit
* If you spawn threads, you are responsible for joining on them so that the application only reaches the termination of the main thread when the application is ready to exit.
* In order for this to work, I removed all instances in the codebase where RuntimeException, Exception, Error, or Throwable are caught (except org.kframework.backend.kil.KItem.java). I also removed all instances in the codebase where Exception or Throwable were explicitly thrown.
** I added a checkstyle check to ensure that this property is not violated.
** It is now an antipattern to catch an exception, print a stack trace, and do nothing. The correct course of action is to print a stack trace if GlobalOptions.debug is set in the current option set, and register a KException if the error is unrecoverable.