Avoid creating a throwaway raise exception

In particular, a long error message including the java stack trace was
being built and then discarded.
Merge pull request #1864 from grddev/rewrite-stacktrace-performance

Avoid creating a throwaway raise exception