-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ExternalErrors error type #3280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. I've left a couple of comments with suggestions for improvements if we want to keep an eye towards the future. I'll leave it up to you if you think they are worth it or not.
inputErr bool | ||
externalErr bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be a case for changing these into a single enum field if they are mutually exclusive. I'll leave it up to you though.
internal/runners/initialize/init.go
Outdated
@@ -189,10 +189,10 @@ func (r *Initialize) Run(params *RunParams) (rerr error) { | |||
|
|||
version, err := deriveVersion(lang, languageVersion, r.auth) | |||
if err != nil { | |||
if inferred || !locale.IsInputError(err) { | |||
if inferred || (!locale.IsInputError(err) && !errs.IsExternalError(err)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is at least the second time I've seen this. Would it make sense to add a function that would wrap this so if we were to add more types of errors, we'd only have to change that function instead of all of these instances?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good idea. Thanks for the suggestion.
@@ -143,10 +143,10 @@ func confirmLock(prom prompt.Prompter) error { | |||
return nil | |||
} | |||
|
|||
func fetchExactVersion(an analytics.Dispatcher, svc *model.SvcModel, channel, version string) (string, error) { | |||
func fetchExactVersion(svc *model.SvcModel, channel, version string) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for catching this unused parameter and removing it!
The major changes are in
internal/errs/errs.go
andinternal/locale/errors.go
. The rest of the changeset it updating user input errors to external errors. I tried to catch as many as I could. The vast majority ofNewInputError
calls are correct so this mostly updates the wrapped errors.