Making error messages for failed jobs more informative

and DRYing things up.