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
To enhance readability by reducing the level of nesting. Very deep nested code is difficult to reason about, and error handling tends to move far away from the error source.