Skip to content

Commit

Permalink
add error return value to recover
Browse files Browse the repository at this point in the history
  • Loading branch information
omryMen committed Apr 30, 2024
1 parent bf08a2c commit d3d1064
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/common/gitservice/git_service.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package gitservice

import (
"errors"
"fmt"
"github.com/pkg/errors"

Check failure on line 5 in src/common/gitservice/git_service.go

View workflow job for this annotation

GitHub Actions / golangci-lint

[golangci-lint] src/common/gitservice/git_service.go#L5

File is not `goimports`-ed (goimports)
Raw output
src/common/gitservice/git_service.go:5: File is not `goimports`-ed (goimports)
	"github.com/pkg/errors"
"io"
"log"
"os"
"os/exec"
"path/filepath"
"runtime/debug"
"strings"
"sync"

Expand Down Expand Up @@ -140,14 +141,12 @@ func (g *GitService) GetRepoName() string {
return g.repoName
}

func wrapGitBlame(selectedCommit *object.Commit, relativeFilePath string) (*git.BlameResult, error) {
func wrapGitBlame(selectedCommit *object.Commit, relativeFilePath string) (blame *git.BlameResult, err error) {
// currently there's a bug inside go-git so in order to mitigate it we wrap it with recover
var err error
var blame *git.BlameResult
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
err = errors.New("unknown panic")
fmt.Println("Recovered in f", r, debug.Stack())
err = errors.Errorf("unknown panic, %v", r)
}
}()
blame, err = git.Blame(selectedCommit, relativeFilePath)
Expand Down

0 comments on commit d3d1064

Please sign in to comment.