Skip to content

Commit

Permalink
Added notes on UPGRADING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Aug 11, 2021
1 parent d656f19 commit acab430
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,51 @@ Here you can find a list of migration guides to handle breaking changes between

## Unreleased

### Change in `github.com/arduino/arduino-cli/commands/*` package functions signature

The `error` returned from each function in this package (and his subpackages) has been changed into a gRPC
status `*status.Status` object.
The rationale behind this change is that each function in the `commands` package has a direct counterpart in
the gRPC server API, but the `error` type do not map exactly the way the gRPC protocol handles error.
The `Status` object may be decorated with `Status.Details` that may give, in some circumstances, more
detailed information on the cause of a failure.

From the "gRPC client" point of view, this change should not break because a failing gRPC call is still
failing after this change.

From the "golang import" point of view, this is a breaking change because where previously we had an `error`
now we get a `*status.Status`. Let's look, for example, at the `board.Details` function:

```go
func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
```
Now has been changed to:
```go
func Details(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, *status.Status) {
```
so if previously we used to handle the error in the usual golang way:
```go
detailsResp, err := board.Details(context.Background(), detailsReq)
if err != nil {
fmt.Println("Error getting board details:", err)
return
}
```
now we must unwrap the error message from the `Status` object:
```go
detailsResp, stat := board.Details(context.Background(), detailsReq)
if stat != nil {
fmt.Println("Error getting board details:", stat.Message())
return
}
```
### Change public library interface
#### `github.com/arduino/arduino-cli/i18n` package
Expand Down

0 comments on commit acab430

Please sign in to comment.