Restore exception handler, add on_problem event

- let's call the previously set exception handler (if set)
- let's fire a new 'on_problem' event, so that users can take their own
  actions (ex send a notification email)
- let's save to a customizable logfile if saving to db fails