Skip to content

fix(git_service): throw errors when git command fails, don't return null

Motivation for the refactoring

The extension has an ongoing problem with critical errors being swallowed by some low-level service (git_service, gitlab_service). Instead of being thrown, the critical error gets turned into null that gets passed around which results in a failure in a seemingly unrelated code.

We made a good step towards error discovery in !99 (merged) where we logged all the errors. Unfortunately, that still isn't enough to easily debug the issue, because we log an error but continue executing code that doesn't have a chance of succeeding.

MR explained

This MR looks at the git_service, and it removes most of the catch(e){return null} statements. Instead, the service throws when it encounters a critical error.

The implementation is split into meaningful commits that can be reviewed separately.

The first commit removes the catch-all try/catch statement from the git_service.fetch() function and instead pushes these try/catch statements to the public functions. The following commits are then removing the try/catch from different public methods of git_service. I chose this approach to be able to follow the usage of each git_service public functions and see if the client code can handle the thrown exception.

The last commit slightly improves how we display failure in the tree view (side bar).

Related to #265 (closed) Related to #278 (closed)

Edited by Tomas Vik (OOO back on 2024-07-02)

Merge request reports