Added an error handler, which produces a stack trace for errors.