Factor out the calling of args.func into a function

This makes it possible to do the same catching of RuntimeError in external
packages like conda-build.