Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
New error message. (#912)
Browse files Browse the repository at this point in the history
* New Error Message

Signed-off-by: maurineimirandazup <[email protected]>

* Rename variable name, change error msg

Signed-off-by: maurineimirandazup <[email protected]>
  • Loading branch information
maurineimirandazup authored Apr 22, 2021
1 parent b765170 commit abcfce5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
11 changes: 7 additions & 4 deletions pkg/formula/builder/bat.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import (

const (
buildBat = "build.bat"
msgBatBuildErr = "failed building formula with build.bat, verify your repository"
errMsgFmt = `%s
More about error: %s`
msgBatBuildErr = "Check if you have all the requirements to execute this formula."
errMsgFmt = "\nError building formula: "
)

var (
Expand Down Expand Up @@ -64,7 +63,11 @@ func (ba BatManager) Build(info formula.BuildInfo) error {
cmd := exec.Command(buildBat)
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf(errMsgFmt, ErrBuildFormulaBuildBat, stderr.String())
return errors.New(
fmt.Sprint(
prompt.Red(ErrBuildFormulaBuildBat.Error()),
errMsgFmt+prompt.Red(stderr.String()),
))
}

return nil
Expand Down
9 changes: 7 additions & 2 deletions pkg/formula/builder/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
"os/exec"

"github.com/ZupIT/ritchie-cli/pkg/formula"
"github.com/ZupIT/ritchie-cli/pkg/prompt"
)

const msgMakeBuildErr = "failed building formula with Makefile, verify your repository"
const msgMakeBuildErr = "Check if you have all the requirements to execute this formula."

var ErrBuildFormulaMakefile = errors.New(msgMakeBuildErr)

Expand All @@ -46,7 +47,11 @@ func (ma MakeManager) Build(info formula.BuildInfo) error {
cmd := exec.Command("make", "build")
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf(errMsgFmt, ErrBuildFormulaMakefile, stderr.String())
return errors.New(
fmt.Sprint(
prompt.Red(ErrBuildFormulaMakefile.Error()),
errMsgFmt+prompt.Red(stderr.String()),
))
}

return nil
Expand Down
9 changes: 7 additions & 2 deletions pkg/formula/builder/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import (
"path/filepath"

"github.com/ZupIT/ritchie-cli/pkg/formula"
"github.com/ZupIT/ritchie-cli/pkg/prompt"
)

const (
buildSh = "build.sh"
msgShellBuildErr = "failed building formula with shell script, verify your repository"
msgShellBuildErr = "Check if you have all the requirements to execute this formula."
)

var ErrBuildFormulaShell = errors.New(msgShellBuildErr)
Expand All @@ -52,7 +53,11 @@ func (sh ShellManager) Build(info formula.BuildInfo) error {
cmd := exec.Command(execFile) //nolint:gosec
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf(errMsgFmt, ErrBuildFormulaShell, stderr.String())
return errors.New(
fmt.Sprint(
prompt.Red(ErrBuildFormulaShell.Error()),
errMsgFmt+prompt.Red(stderr.String()),
))
}

return nil
Expand Down

0 comments on commit abcfce5

Please sign in to comment.