Added a copy of code from ExceptionHandler.java

Just a random code snippet from the toucan codebase.