Refactor ContributionManager code

 * Change argument types to take generic `ProgressMonitor` instances.
 * Move error handling code closer to the error source.
 * Reduce nesting to make code easier to follow and reason about.

Some deeper code changes to reduce duplication are outside the scope of this PR.

This may also make it easier to solve #2798. cc/ @joelmoniz
That's bad practice: the object is only used inside the block. The change adds more lines of code *and* keeps the object around longer during runtime.