Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Better gRPC error handling #1251

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

Merged
merged 19 commits into from
Aug 30, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle details of any type in core.PlatformUpgrade() status
The status details of the function are used to identify the specific cause of a non-nil status. This is done via a type
assertion. Previously, this type assertion was configured such that a details of any type other than the expected would
result in a panic. At the moment, that will not occur because we only add details of one type. However, the whole point
of the type assertion is to support details of multiple types, and if other types are added a panic will not be the
appropriate behavior.

A better approach is to check the result of the type assertion, handling the non-nil status as a generic error if its
details are of a different type.
  • Loading branch information
per1234 authored and cmaglie committed Aug 28, 2021
commit c6b72b9c81e44ef2e9c03126be52dfe8b178e01a
13 changes: 9 additions & 4 deletions 13 cli/core/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ func runUpgradeCommand(cmd *cobra.Command, args []string) {
}

_, err := core.PlatformUpgrade(context.Background(), r, output.ProgressBar(), output.TaskProgress())
if d := err.Details(); len(d) > 0 && d[0].(*rpc.AlreadyAtLatestVersionError) != nil {
feedback.Printf(tr("Platform %s is already at the latest version", platformRef))
} else if err != nil {
feedback.Errorf(tr("Error during upgrade: %v"), err)
if err != nil {
if d := err.Details(); len(d) > 0 {
if _, ok := d[0].(*rpc.AlreadyAtLatestVersionError); ok {
feedback.Printf(tr("Platform %s is already at the latest version", platformRef))
continue
}
}

feedback.Errorf(tr("Error during upgrade: %v", err))
silvanocerza marked this conversation as resolved.
Show resolved Hide resolved
os.Exit(errorcodes.ErrGeneric)
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.