Skip to content

Commit

Permalink
Change error handling when fallback succeeds with permission error
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgHaj committed May 10, 2023
1 parent 6328c77 commit 183666d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pkg/resolution/pm/gradle/job.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gradle

import (
"errors"
"fmt"
"path/filepath"
"strings"

Expand Down Expand Up @@ -44,9 +44,9 @@ func (j *Job) Run() {

if err != nil {
if strings.HasSuffix(err.Error(), "gradlew\": permission denied") {
permissionDeniedErr := "Permission to execute gradlew is not granted, fallback to PATHs gradle installation will be used.\nFull error: " + err.Error()
permissionErr = fmt.Errorf("Permission to execute gradlew is not granted, fallback to PATHs gradle installation will be used.\nFull error: %s", err.Error())

dependenciesCmd, err = j.cmdFactory.MakeDependenciesGraphCmd(workingDirectory, "gradle", j.groovyInitScript)
permissionErr = errors.New(permissionDeniedErr)
}
}

Expand All @@ -63,11 +63,7 @@ func (j *Job) Run() {
_, err = dependenciesCmd.Output()

if permissionErr != nil {
if err != nil {
j.Errors().Critical(permissionErr)
} else {
j.Errors().Warning(permissionErr)
}
j.Errors().Warning(permissionErr)
}

if err != nil {
Expand Down

0 comments on commit 183666d

Please sign in to comment.