improve error handling for tasks

this unifies error handling in tasks

will probably have to re-test this on staging