Modify generic exception handling so that StackOverflowError is not treated as a fatal error and can handled and/or logged as required.