refactor: replace errgo and pkg/errors with github.com/Scalingo/go-utils/errors/v3#1196
refactor: replace errgo and pkg/errors with github.com/Scalingo/go-utils/errors/v3#1196
errgo and pkg/errors with github.com/Scalingo/go-utils/errors/v3#1196Conversation
c3fbc95 to
09876a8
Compare
5fd4404 to
5477e2b
Compare
c8add97 to
5c42416
Compare
70613aa to
d5fd770
Compare
SCedricThomas
left a comment
There was a problem hiding this comment.
Just some questions and fix to make. Thanks for taking care of this
env/display.go
Outdated
| } | ||
| } | ||
| return "", errors.New("environment variable not found") | ||
| return "", stderrors.New("environment variable not found") |
There was a problem hiding this comment.
issue: you should use the go-utils/error/v3 package as you have access to a context
cmd/integration_link.go
Outdated
| return errors.Wrapf(ctx, err, "error parsing hours") | ||
| } | ||
| if i < 0 { | ||
| return stderrors.New("must be positive") |
There was a problem hiding this comment.
question: can we use go-utils/error/v3 errors here? I saw that we are capturing the parent scope context but it should be possible as you used it to call errors.Wrapf on line 506
cmd/integration_link.go
Outdated
| return func(ans any) error { | ||
| str, ok := ans.(string) | ||
| if !ok { | ||
| return stderrors.New("must be a string") |
There was a problem hiding this comment.
question: can we use go-utils/error/v3 errors here? I saw that we are capturing the parent scope context but it should be possible as you used it to call errors.Wrapf on line 506
cmd/integration_link.go
Outdated
| var params scalingo.SCMRepoLinkCreateParams | ||
| if config.C.DisableInteractive { | ||
| return params, errors.New("need at least one integration link parameter") | ||
| return params, stderrors.New("need at least one integration link parameter") |
There was a problem hiding this comment.
issue: you should use the go-utils/errors/v3 package here
cmd/integration_link.go
Outdated
| noAutoDeploy := c.Bool("no-auto-deploy") | ||
| if autoDeploy && noAutoDeploy { | ||
| errorQuitWithHelpMessage(ctx, errors.New("cannot define both auto-deploy and no-auto-deploy"), c, "integration-link-update") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("cannot define both auto-deploy and no-auto-deploy"), c, "integration-link-update") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? We have access to a context
cmd/integration_link.go
Outdated
|
|
||
| if allowReviewAppsFromForks && noAllowReviewAppsFromForks { | ||
| errorQuitWithHelpMessage(ctx, errors.New("cannot define both allow-review-apps-from-forks and no-allow-review-apps-from-forks"), c, "integration-link-update") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("cannot define both allow-review-apps-from-forks and no-allow-review-apps-from-forks"), c, "integration-link-update") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? We have access to a context
cmd/integration_link.go
Outdated
|
|
||
| if awareOfSecurityRisks && !c.IsSet("allow-review-apps-from-forks") { | ||
| errorQuitWithHelpMessage(ctx, errors.New("flag --aware-of-security-risks must be used in conjunction with --allow-review-apps-from-forks"), c, "integration-link-update") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("flag --aware-of-security-risks must be used in conjunction with --allow-review-apps-from-forks"), c, "integration-link-update") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? We have access to a context
cmd/integration_link.go
Outdated
|
|
||
| if awareOfSecurityRisks && !c.IsSet("allow-review-apps-from-forks") { | ||
| errorQuitWithHelpMessage(ctx, errors.New("flag --aware-of-security-risks must be used in conjunction with --allow-review-apps-from-forks"), c, "integration-link-create") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("flag --aware-of-security-risks must be used in conjunction with --allow-review-apps-from-forks"), c, "integration-link-create") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? We have access to a context
cmd/integration_link.go
Outdated
|
|
||
| if allowReviewAppsFromForks && noAllowReviewAppsFromForks { | ||
| errorQuitWithHelpMessage(ctx, errors.New("cannot define both allow-review-apps-from-forks and no-allow-review-apps-from-forks"), c, "integration-link-create") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("cannot define both allow-review-apps-from-forks and no-allow-review-apps-from-forks"), c, "integration-link-create") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? We have access to a context
cmd/integration_link.go
Outdated
| noDestroyOnStale := c.Bool("no-destroy-on-stale") | ||
| if destroyOnStale && noDestroyOnStale { | ||
| errorQuitWithHelpMessage(ctx, errors.New("cannot define both destroy-on-stale and no-destroy-on-stale"), c, "integration-link-create") | ||
| errorQuitWithHelpMessage(ctx, stderrors.New("cannot define both destroy-on-stale and no-destroy-on-stale"), c, "integration-link-create") |
There was a problem hiding this comment.
question: Why not using go-utils/errors/v3 package here? Same for above
There was a problem hiding this comment.
Nice catch, I fixed all your comments in b662bda
Uh oh!
There was an error while loading. Please reload this page.