Misc errors when errors happen

When things go really wrong, a lot more things also go wrong.

(NB this builds on #83 at present, so merge that first.)

The exception's stacktrace will never be logged. We need to log all stacktraces at least at debug, at least (and ideally) once. Could do that in the try-catch above.