Skip to content

Commit

Permalink
Use shared error components (#93)
Browse files Browse the repository at this point in the history
* Update dependencies

* Use shared error formatter

* Remove error wrapping

* Fix comments
  • Loading branch information
tothszabi authored Dec 12, 2022
1 parent f3b6889 commit 6b45574
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 38 deletions.
1 change: 0 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ func (f FastlaneRunner) checkForRbenv(workDir string) {

f.logger.Donef("$ %s", cmd.PrintableCommandArgs())
if err := cmd.Run(); err != nil {
err := f.wrapCommandError(cmd, err)
f.logger.Warnf(err.Error())
}
}
Expand Down
8 changes: 4 additions & 4 deletions dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {
f.logger.Println()

if err := cmd.Run(); err != nil {
return f.wrapCommandError(cmd, err)
return err
}
}

Expand All @@ -51,7 +51,7 @@ func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {
f.logger.Println()

if err := cmd.Run(); err != nil {
return f.wrapCommandError(cmd, err)
return err
}
} else if opts.UpdateFastlane {
f.logger.Println()
Expand All @@ -66,7 +66,7 @@ func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {
f.logger.Donef("$ %s", cmd.PrintableCommandArgs())

if err := cmd.Run(); err != nil {
return f.wrapCommandError(cmd, err)
return err
}
}
} else {
Expand Down Expand Up @@ -94,7 +94,7 @@ func (f FastlaneRunner) InstallDependencies(opts EnsureDependenciesOpts) error {
f.logger.Donef("$ %s", cmd.PrintableCommandArgs())

if err := cmd.Run(); err != nil {
return f.wrapCommandError(cmd, err)
return err
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/bitrise-io/go-steputils v1.0.2
github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.14
github.com/bitrise-io/go-utils v1.0.2
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.15
github.com/bitrise-io/go-xcode v1.0.9
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/stretchr/testify v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ github.com/bitrise-io/go-utils v1.0.2/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.6/go.mod h1:mysJdafur1ytXda0TeRsV+GxYCJFDU0QcCmYBgQf2Fc=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.7/go.mod h1:6i0Gt0JRIbXpsrFDJT1YWghFfdN8qF26/fnpc/6d/88=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.12/go.mod h1:gZWtM7PLn1VOroa4gN1La/24aRVc0jg5R701jTsPaO8=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14 h1:ojxW7IWBXmF2VsmkO+1s1/zSQR7f9DWqphSgcoQbGjw=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14/go.mod h1:Laih4ji980SQkRgdnMCH0g4u2GZI/5nnbqmYT9UfKFQ=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.15 h1:ERQb+OOa+eKMWb+HByyPd5ugz6TeaJPnQ3xHgyaR7hA=
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.15/go.mod h1:Laih4ji980SQkRgdnMCH0g4u2GZI/5nnbqmYT9UfKFQ=
github.com/bitrise-io/go-xcode v1.0.6/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY=
github.com/bitrise-io/go-xcode v1.0.9 h1:+sbqOYidQ+aiFfCTDpf2LdGSQEM5RfbtDsiG27zJG+s=
github.com/bitrise-io/go-xcode v1.0.9/go.mod h1:Y0Wu2dXm0MilJ/4D3+gPHaNMlUcP+1DjIPoLPykq7wY=
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/bitrise-io/go-steputils/v2/stepconf"
"github.com/bitrise-io/go-utils/v2/command"
"github.com/bitrise-io/go-utils/v2/env"
"github.com/bitrise-io/go-utils/v2/errorutil"
. "github.com/bitrise-io/go-utils/v2/exitcode"
"github.com/bitrise-io/go-utils/v2/log"
"github.com/bitrise-io/go-utils/v2/pathutil"
Expand All @@ -25,7 +26,7 @@ func run() ExitCode {
config, err := buildStep.ProcessConfig()
if err != nil {
buildStep.logger.Println()
buildStep.logger.Errorf(formattedError(fmt.Errorf("Failed to process Step inputs: %w", err)))
buildStep.logger.Errorf(errorutil.FormattedError(fmt.Errorf("Failed to process Step inputs: %w", err)))
return Failure
}

Expand All @@ -38,14 +39,14 @@ func run() ExitCode {

if err := buildStep.InstallDependencies(dependenciesOpts); err != nil {
buildStep.logger.Println()
buildStep.logger.Errorf(formattedError(fmt.Errorf("Failed to install Step dependencies: %w", err)))
buildStep.logger.Errorf(errorutil.FormattedError(fmt.Errorf("Failed to install Step dependencies: %w", err)))
return Failure
}

runOpts := createRunOptions(config)
if err := buildStep.Run(runOpts); err != nil {
buildStep.logger.Println()
logger.Errorf(formattedError(fmt.Errorf("Failed to execute Step main logic: %w", err)))
logger.Errorf(errorutil.FormattedError(fmt.Errorf("Failed to execute Step: %w", err)))
return Failure
}

Expand Down
2 changes: 1 addition & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ you can find the output of fastlane env in the following log file: %s`, deployPt
f.logger.Warnf("Failed to walk directory, error: %s", err)
}

return fmt.Errorf("running Fastlane failed: %w", f.wrapCommandError(cmd, fastlaneErr))
return fmt.Errorf("running Fastlane failed: %w", fastlaneErr)
}

f.cacheDeps(opts)
Expand Down
98 changes: 88 additions & 10 deletions vendor/github.com/bitrise-io/go-utils/v2/command/command.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions vendor/github.com/bitrise-io/go-utils/v2/command/errorcollector.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ github.com/bitrise-io/go-utils/parseutil
github.com/bitrise-io/go-utils/pathutil
github.com/bitrise-io/go-utils/pointers
github.com/bitrise-io/go-utils/sliceutil
# github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14
# github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.15
## explicit; go 1.17
github.com/bitrise-io/go-utils/v2/command
github.com/bitrise-io/go-utils/v2/env
github.com/bitrise-io/go-utils/v2/errorutil
github.com/bitrise-io/go-utils/v2/exitcode
github.com/bitrise-io/go-utils/v2/log
github.com/bitrise-io/go-utils/v2/log/colorstring
Expand Down

0 comments on commit 6b45574

Please sign in to comment.