I refreshed, and changed, the original patch.
Patch 1a will log exceptions to a file called 'error-stacktrace.out' in the same directory as derby.log and the database are saved. If copying the log file or the database fail, that exception will also be logged to the file.
To avoid overwriting potentially valuable information, the file is opened in append mode. The time and date are written as a header before the exception stack trace is written.
I have tested the patch manually (by throwing an exception in a test, and also by removing the write privileges on the derby.log file), and will start the regression tests.
Patch ready for review.