-
Notifications
You must be signed in to change notification settings - Fork 24
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 informative error #602
Add informative error #602
Conversation
fc6e04a
to
ce87828
Compare
apps/scale.go
Outdated
@@ -107,6 +109,13 @@ func Scale(app string, sync bool, types []string) error { | |||
res, err := c.AppsScale(app, scaleParams) | |||
if err != nil { | |||
if !utils.IsPaymentRequiredAndFreeTrialExceededError(err) { | |||
reqestFailedError, _ := errors.ErrgoRoot(err).(*http.RequestFailedError) |
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.
reqestFailedError, _ := errors.ErrgoRoot(err).(*http.RequestFailedError) | |
reqestFailedError, ok := errors.ErrgoRoot(err).(*http.RequestFailedError) |
Shouldn't you test the ok
value? What happens if the error is not of type http.RequestFailedError
? 🤔
apps/scale.go
Outdated
@@ -107,6 +109,13 @@ func Scale(app string, sync bool, types []string) error { | |||
res, err := c.AppsScale(app, scaleParams) | |||
if err != nil { | |||
if !utils.IsPaymentRequiredAndFreeTrialExceededError(err) { | |||
reqestFailedError, _ := errors.ErrgoRoot(err).(*http.RequestFailedError) | |||
|
|||
// In case of unprocessable, format and return an clear 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.
// In case of unprocessable, format and return an clear error | |
// In case of unprocessable, format and return a clear error |
|
||
// In case of unprocessable, format and return an clear error | ||
if reqestFailedError.Code == 422 { | ||
return formatContainerTypesError(c, app, reqestFailedError) |
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.
In case of error formatting the error message, I wouldn't return the error. I think it would be best to:
- Log the error
- Display the error message contained in
requestFailedError
. This error message is already a good error message. If we fail to enrich it with more informative information, we don't want to lose the source of the error message. Don't you think?
Related to OPSB-49 |
Co-authored-by: Étienne M. <EtienneM@users.noreply.github.com>
Now errors are printed like:
Related to https://github.com/Scalingo/api/pull/1799
Related to https://github.com/Scalingo/one-stop-shop/issues/191
Related to OPSB-49