dispatch: split global error handling out so it can be reused
We may want a similar error handling at worker.py. This patch extracts the
error handling logic to "callcatch" so it can be reused.
#require docutils gettext $ $TESTDIR/check-gendoc fr checking for parse errors