Add better exception handling.

Catch exceptions in subtasks and allow others to continue, as discussed in [our discussion](https://github.com/duedil-ltd/portainer/commit/534a6e7da339cff292292b4d6d637eb23f7f96df#commitcomment-8347717)