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
Why is this hoisted outside the block?