@@ -4,6 +4,51 @@ Here you can find a list of migration guides to handle breaking changes between
44
55## Unreleased
66
7+ ### Change in ` github.com/arduino/arduino-cli/commands/* ` package functions signature
8+
9+ The ` error ` returned from each function in this package (and his subpackages) has been changed into a gRPC
10+ status ` *status.Status ` object.
11+ The rationale behind this change is that each function in the ` commands ` package has a direct counterpart in
12+ the gRPC server API, but the ` error ` type do not map exactly the way the gRPC protocol handles error.
13+ The ` Status ` object may be decorated with ` Status.Details ` that may give, in some circumstances, more
14+ detailed information on the cause of a failure.
15+
16+ From the "gRPC client" point of view, this change should not break because a failing gRPC call is still
17+ failing after this change.
18+
19+ From the "golang import" point of view, this is a breaking change because where previously we had an ` error `
20+ now we get a ` *status.Status ` . Let's look, for example, at the ` board.Details ` function:
21+
22+ ``` go
23+ func Details (ctx context .Context , req *rpc .BoardDetailsRequest ) (*rpc .BoardDetailsResponse , error ) {
24+ ` ` `
25+
26+ Now has been changed to:
27+
28+ ` ` ` go
29+ func Details (ctx context.Context , req *rpc.BoardDetailsRequest ) (*rpc.BoardDetailsResponse , *status.Status ) {
30+ ` ` `
31+
32+ so if previously we used to handle the error in the usual golang way:
33+
34+ ` ` ` go
35+ detailsResp , err := board.Details (context.Background (), detailsReq)
36+ if err != nil {
37+ fmt.Println (" Error getting board details:" , err)
38+ return
39+ }
40+ ` ` `
41+
42+ now we must unwrap the error message from the ` Status` object:
43+
44+ ` ` ` go
45+ detailsResp , stat := board.Details (context.Background (), detailsReq)
46+ if stat != nil {
47+ fmt.Println (" Error getting board details:" , stat.Message ())
48+ return
49+ }
50+ ` ` `
51+
752### Change public library interface
853
954#### ` github.com /arduino/arduino-cli/i18n` package
0 commit comments