Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee52f06

Browse files
committedMar 13, 2024
Removed ToRPCStatus in favor of standardized GRPCStatus() interface
This change avoids the ugly 'convertErrorToRPCStatus' helper method since the gRPC server automatically recognize if the error implements the `GRPCStatus() *Status` interface method.
1 parent 52f80e6 commit ee52f06

File tree

5 files changed

+149
-185
lines changed

5 files changed

+149
-185
lines changed
 

‎commands/cmderrors/cmderrors.go

Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ func composeErrorMsg(msg string, cause error) string {
3737

3838
// CommandError is an error that may be converted into a gRPC status.
3939
type CommandError interface {
40-
// ToRPCStatus convertes the error into a *status.Status
41-
ToRPCStatus() *status.Status
40+
// GRPCStatus convertes the error into a *status.Status
41+
GRPCStatus() *status.Status
4242
}
4343

4444
// InvalidInstanceError is returned if the instance used in the command is not valid.
@@ -48,8 +48,8 @@ func (e *InvalidInstanceError) Error() string {
4848
return tr("Invalid instance")
4949
}
5050

51-
// ToRPCStatus converts the error into a *status.Status
52-
func (e *InvalidInstanceError) ToRPCStatus() *status.Status {
51+
// GRPCStatus converts the error into a *status.Status
52+
func (e *InvalidInstanceError) GRPCStatus() *status.Status {
5353
return status.New(codes.InvalidArgument, e.Error())
5454
}
5555

@@ -62,8 +62,8 @@ func (e *InvalidFQBNError) Error() string {
6262
return composeErrorMsg(tr("Invalid FQBN"), e.Cause)
6363
}
6464

65-
// ToRPCStatus converts the error into a *status.Status
66-
func (e *InvalidFQBNError) ToRPCStatus() *status.Status {
65+
// GRPCStatus converts the error into a *status.Status
66+
func (e *InvalidFQBNError) GRPCStatus() *status.Status {
6767
return status.New(codes.InvalidArgument, e.Error())
6868
}
6969

@@ -80,8 +80,8 @@ func (e *InvalidURLError) Error() string {
8080
return composeErrorMsg(tr("Invalid URL"), e.Cause)
8181
}
8282

83-
// ToRPCStatus converts the error into a *status.Status
84-
func (e *InvalidURLError) ToRPCStatus() *status.Status {
83+
// GRPCStatus converts the error into a *status.Status
84+
func (e *InvalidURLError) GRPCStatus() *status.Status {
8585
return status.New(codes.InvalidArgument, e.Error())
8686
}
8787

@@ -98,8 +98,8 @@ func (e *InvalidLibraryError) Error() string {
9898
return composeErrorMsg(tr("Invalid library"), e.Cause)
9999
}
100100

101-
// ToRPCStatus converts the error into a *status.Status
102-
func (e *InvalidLibraryError) ToRPCStatus() *status.Status {
101+
// GRPCStatus converts the error into a *status.Status
102+
func (e *InvalidLibraryError) GRPCStatus() *status.Status {
103103
return status.New(codes.InvalidArgument, e.Error())
104104
}
105105

@@ -116,8 +116,8 @@ func (e *InvalidVersionError) Error() string {
116116
return composeErrorMsg(tr("Invalid version"), e.Cause)
117117
}
118118

119-
// ToRPCStatus converts the error into a *status.Status
120-
func (e *InvalidVersionError) ToRPCStatus() *status.Status {
119+
// GRPCStatus converts the error into a *status.Status
120+
func (e *InvalidVersionError) GRPCStatus() *status.Status {
121121
return status.New(codes.InvalidArgument, e.Error())
122122
}
123123

@@ -139,8 +139,8 @@ func (e *NoBoardsDetectedError) Error() string {
139139
)
140140
}
141141

142-
// ToRPCStatus converts the error into a *status.Status
143-
func (e *NoBoardsDetectedError) ToRPCStatus() *status.Status {
142+
// GRPCStatus converts the error into a *status.Status
143+
func (e *NoBoardsDetectedError) GRPCStatus() *status.Status {
144144
return status.New(codes.InvalidArgument, e.Error())
145145
}
146146

@@ -159,8 +159,8 @@ func (e *MultipleBoardsDetectedError) Error() string {
159159
)
160160
}
161161

162-
// ToRPCStatus converts the error into a *status.Status
163-
func (e *MultipleBoardsDetectedError) ToRPCStatus() *status.Status {
162+
// GRPCStatus converts the error into a *status.Status
163+
func (e *MultipleBoardsDetectedError) GRPCStatus() *status.Status {
164164
return status.New(codes.InvalidArgument, e.Error())
165165
}
166166

@@ -171,8 +171,8 @@ func (e *MissingFQBNError) Error() string {
171171
return tr("Missing FQBN (Fully Qualified Board Name)")
172172
}
173173

174-
// ToRPCStatus converts the error into a *status.Status
175-
func (e *MissingFQBNError) ToRPCStatus() *status.Status {
174+
// GRPCStatus converts the error into a *status.Status
175+
func (e *MissingFQBNError) GRPCStatus() *status.Status {
176176
return status.New(codes.InvalidArgument, e.Error())
177177
}
178178

@@ -189,8 +189,8 @@ func (e *UnknownFQBNError) Unwrap() error {
189189
return e.Cause
190190
}
191191

192-
// ToRPCStatus converts the error into a *status.Status
193-
func (e *UnknownFQBNError) ToRPCStatus() *status.Status {
192+
// GRPCStatus converts the error into a *status.Status
193+
func (e *UnknownFQBNError) GRPCStatus() *status.Status {
194194
return status.New(codes.NotFound, e.Error())
195195
}
196196

@@ -208,8 +208,8 @@ func (e *UnknownProfileError) Unwrap() error {
208208
return e.Cause
209209
}
210210

211-
// ToRPCStatus converts the error into a *status.Status
212-
func (e *UnknownProfileError) ToRPCStatus() *status.Status {
211+
// GRPCStatus converts the error into a *status.Status
212+
func (e *UnknownProfileError) GRPCStatus() *status.Status {
213213
return status.New(codes.NotFound, e.Error())
214214
}
215215

@@ -226,8 +226,8 @@ func (e *InvalidProfileError) Unwrap() error {
226226
return e.Cause
227227
}
228228

229-
// ToRPCStatus converts the error into a *status.Status
230-
func (e *InvalidProfileError) ToRPCStatus() *status.Status {
229+
// GRPCStatus converts the error into a *status.Status
230+
func (e *InvalidProfileError) GRPCStatus() *status.Status {
231231
return status.New(codes.FailedPrecondition, e.Error())
232232
}
233233

@@ -238,8 +238,8 @@ func (e *MissingPortAddressError) Error() string {
238238
return tr("Missing port address")
239239
}
240240

241-
// ToRPCStatus converts the error into a *status.Status
242-
func (e *MissingPortAddressError) ToRPCStatus() *status.Status {
241+
// GRPCStatus converts the error into a *status.Status
242+
func (e *MissingPortAddressError) GRPCStatus() *status.Status {
243243
return status.New(codes.InvalidArgument, e.Error())
244244
}
245245

@@ -250,8 +250,8 @@ func (e *MissingPortProtocolError) Error() string {
250250
return tr("Missing port protocol")
251251
}
252252

253-
// ToRPCStatus converts the error into a *status.Status
254-
func (e *MissingPortProtocolError) ToRPCStatus() *status.Status {
253+
// GRPCStatus converts the error into a *status.Status
254+
func (e *MissingPortProtocolError) GRPCStatus() *status.Status {
255255
return status.New(codes.InvalidArgument, e.Error())
256256
}
257257

@@ -262,8 +262,8 @@ func (e *MissingPortError) Error() string {
262262
return tr("Missing port")
263263
}
264264

265-
// ToRPCStatus converts the error into a *status.Status
266-
func (e *MissingPortError) ToRPCStatus() *status.Status {
265+
// GRPCStatus converts the error into a *status.Status
266+
func (e *MissingPortError) GRPCStatus() *status.Status {
267267
return status.New(codes.InvalidArgument, e.Error())
268268
}
269269

@@ -276,8 +276,8 @@ func (e *NoMonitorAvailableForProtocolError) Error() string {
276276
return tr("No monitor available for the port protocol %s", e.Protocol)
277277
}
278278

279-
// ToRPCStatus converts the error into a *status.Status
280-
func (e *NoMonitorAvailableForProtocolError) ToRPCStatus() *status.Status {
279+
// GRPCStatus converts the error into a *status.Status
280+
func (e *NoMonitorAvailableForProtocolError) GRPCStatus() *status.Status {
281281
return status.New(codes.InvalidArgument, e.Error())
282282
}
283283

@@ -288,8 +288,8 @@ func (e *MissingProgrammerError) Error() string {
288288
return tr("Missing programmer")
289289
}
290290

291-
// ToRPCStatus converts the error into a *status.Status
292-
func (e *MissingProgrammerError) ToRPCStatus() *status.Status {
291+
// GRPCStatus converts the error into a *status.Status
292+
func (e *MissingProgrammerError) GRPCStatus() *status.Status {
293293
s, _ := status.New(codes.InvalidArgument, e.Error()).WithDetails(&rpc.MissingProgrammerError{})
294294
return s
295295
}
@@ -301,8 +301,8 @@ func (e *ProgrammerRequiredForUploadError) Error() string {
301301
return tr("A programmer is required to upload")
302302
}
303303

304-
// ToRPCStatus converts the error into a *status.Status
305-
func (e *ProgrammerRequiredForUploadError) ToRPCStatus() *status.Status {
304+
// GRPCStatus converts the error into a *status.Status
305+
func (e *ProgrammerRequiredForUploadError) GRPCStatus() *status.Status {
306306
st, _ := status.
307307
New(codes.InvalidArgument, e.Error()).
308308
WithDetails(&rpc.ProgrammerIsRequiredForUploadError{})
@@ -320,8 +320,8 @@ func (ife *InitFailedError) Error() string {
320320
return ife.Cause.Error()
321321
}
322322

323-
// ToRPCStatus converts the error into a *status.Status
324-
func (ife *InitFailedError) ToRPCStatus() *status.Status {
323+
// GRPCStatus converts the error into a *status.Status
324+
func (ife *InitFailedError) GRPCStatus() *status.Status {
325325
st, _ := status.
326326
New(ife.Code, ife.Cause.Error()).
327327
WithDetails(&rpc.FailedInstanceInitError{
@@ -345,8 +345,8 @@ func (e *ProgrammerNotFoundError) Unwrap() error {
345345
return e.Cause
346346
}
347347

348-
// ToRPCStatus converts the error into a *status.Status
349-
func (e *ProgrammerNotFoundError) ToRPCStatus() *status.Status {
348+
// GRPCStatus converts the error into a *status.Status
349+
func (e *ProgrammerNotFoundError) GRPCStatus() *status.Status {
350350
return status.New(codes.NotFound, e.Error())
351351
}
352352

@@ -364,8 +364,8 @@ func (e *MonitorNotFoundError) Unwrap() error {
364364
return e.Cause
365365
}
366366

367-
// ToRPCStatus converts the error into a *status.Status
368-
func (e *MonitorNotFoundError) ToRPCStatus() *status.Status {
367+
// GRPCStatus converts the error into a *status.Status
368+
func (e *MonitorNotFoundError) GRPCStatus() *status.Status {
369369
return status.New(codes.NotFound, e.Error())
370370
}
371371

@@ -379,8 +379,8 @@ func (e *InvalidPlatformPropertyError) Error() string {
379379
return tr("Invalid '%[1]s' property: %[2]s", e.Property, e.Value)
380380
}
381381

382-
// ToRPCStatus converts the error into a *status.Status
383-
func (e *InvalidPlatformPropertyError) ToRPCStatus() *status.Status {
382+
// GRPCStatus converts the error into a *status.Status
383+
func (e *InvalidPlatformPropertyError) GRPCStatus() *status.Status {
384384
return status.New(codes.FailedPrecondition, e.Error())
385385
}
386386

@@ -393,8 +393,8 @@ func (e *MissingPlatformPropertyError) Error() string {
393393
return tr("Property '%s' is undefined", e.Property)
394394
}
395395

396-
// ToRPCStatus converts the error into a *status.Status
397-
func (e *MissingPlatformPropertyError) ToRPCStatus() *status.Status {
396+
// GRPCStatus converts the error into a *status.Status
397+
func (e *MissingPlatformPropertyError) GRPCStatus() *status.Status {
398398
return status.New(codes.FailedPrecondition, e.Error())
399399
}
400400

@@ -408,8 +408,8 @@ func (e *PlatformNotFoundError) Error() string {
408408
return composeErrorMsg(tr("Platform '%s' not found", e.Platform), e.Cause)
409409
}
410410

411-
// ToRPCStatus converts the error into a *status.Status
412-
func (e *PlatformNotFoundError) ToRPCStatus() *status.Status {
411+
// GRPCStatus converts the error into a *status.Status
412+
func (e *PlatformNotFoundError) GRPCStatus() *status.Status {
413413
return status.New(codes.FailedPrecondition, e.Error())
414414
}
415415

@@ -426,8 +426,8 @@ func (e *PlatformLoadingError) Error() string {
426426
return composeErrorMsg(tr("Error loading hardware platform"), e.Cause)
427427
}
428428

429-
// ToRPCStatus converts the error into a *status.Status
430-
func (e *PlatformLoadingError) ToRPCStatus() *status.Status {
429+
// GRPCStatus converts the error into a *status.Status
430+
func (e *PlatformLoadingError) GRPCStatus() *status.Status {
431431
s, _ := status.New(codes.FailedPrecondition, e.Error()).
432432
WithDetails(&rpc.PlatformLoadingError{})
433433
return s
@@ -447,8 +447,8 @@ func (e *LibraryNotFoundError) Error() string {
447447
return composeErrorMsg(tr("Library '%s' not found", e.Library), e.Cause)
448448
}
449449

450-
// ToRPCStatus converts the error into a *status.Status
451-
func (e *LibraryNotFoundError) ToRPCStatus() *status.Status {
450+
// GRPCStatus converts the error into a *status.Status
451+
func (e *LibraryNotFoundError) GRPCStatus() *status.Status {
452452
return status.New(codes.FailedPrecondition, e.Error())
453453
}
454454

@@ -466,8 +466,8 @@ func (e *LibraryDependenciesResolutionFailedError) Error() string {
466466
return composeErrorMsg(tr("No valid dependencies solution found"), e.Cause)
467467
}
468468

469-
// ToRPCStatus converts the error into a *status.Status
470-
func (e *LibraryDependenciesResolutionFailedError) ToRPCStatus() *status.Status {
469+
// GRPCStatus converts the error into a *status.Status
470+
func (e *LibraryDependenciesResolutionFailedError) GRPCStatus() *status.Status {
471471
return status.New(codes.FailedPrecondition, e.Error())
472472
}
473473

@@ -484,8 +484,8 @@ func (e *PlatformAlreadyAtTheLatestVersionError) Error() string {
484484
return tr("Platform '%s' is already at the latest version", e.Platform)
485485
}
486486

487-
// ToRPCStatus converts the error into a *status.Status
488-
func (e *PlatformAlreadyAtTheLatestVersionError) ToRPCStatus() *status.Status {
487+
// GRPCStatus converts the error into a *status.Status
488+
func (e *PlatformAlreadyAtTheLatestVersionError) GRPCStatus() *status.Status {
489489
st, _ := status.
490490
New(codes.AlreadyExists, e.Error()).
491491
WithDetails(&rpc.AlreadyAtLatestVersionError{})
@@ -499,8 +499,8 @@ func (e *MissingSketchPathError) Error() string {
499499
return tr("Missing sketch path")
500500
}
501501

502-
// ToRPCStatus converts the error into a *status.Status
503-
func (e *MissingSketchPathError) ToRPCStatus() *status.Status {
502+
// GRPCStatus converts the error into a *status.Status
503+
func (e *MissingSketchPathError) GRPCStatus() *status.Status {
504504
return status.New(codes.InvalidArgument, e.Error())
505505
}
506506

@@ -543,8 +543,8 @@ func (e *CantOpenSketchError) Unwrap() error {
543543
return e.Cause
544544
}
545545

546-
// ToRPCStatus converts the error into a *status.Status
547-
func (e *CantOpenSketchError) ToRPCStatus() *status.Status {
546+
// GRPCStatus converts the error into a *status.Status
547+
func (e *CantOpenSketchError) GRPCStatus() *status.Status {
548548
return status.New(codes.NotFound, e.Error())
549549
}
550550

@@ -562,8 +562,8 @@ func (e *FailedInstallError) Unwrap() error {
562562
return e.Cause
563563
}
564564

565-
// ToRPCStatus converts the error into a *status.Status
566-
func (e *FailedInstallError) ToRPCStatus() *status.Status {
565+
// GRPCStatus converts the error into a *status.Status
566+
func (e *FailedInstallError) GRPCStatus() *status.Status {
567567
return status.New(codes.Internal, e.Error())
568568
}
569569

@@ -580,8 +580,8 @@ func (e *FailedLibraryInstallError) Unwrap() error {
580580
return e.Cause
581581
}
582582

583-
// ToRPCStatus converts the error into a *status.Status
584-
func (e *FailedLibraryInstallError) ToRPCStatus() *status.Status {
583+
// GRPCStatus converts the error into a *status.Status
584+
func (e *FailedLibraryInstallError) GRPCStatus() *status.Status {
585585
return status.New(codes.Internal, e.Error())
586586
}
587587

@@ -599,8 +599,8 @@ func (e *FailedUninstallError) Unwrap() error {
599599
return e.Cause
600600
}
601601

602-
// ToRPCStatus converts the error into a *status.Status
603-
func (e *FailedUninstallError) ToRPCStatus() *status.Status {
602+
// GRPCStatus converts the error into a *status.Status
603+
func (e *FailedUninstallError) GRPCStatus() *status.Status {
604604
return status.New(codes.Internal, e.Error())
605605
}
606606

@@ -618,8 +618,8 @@ func (e *FailedDownloadError) Unwrap() error {
618618
return e.Cause
619619
}
620620

621-
// ToRPCStatus converts the error into a *status.Status
622-
func (e *FailedDownloadError) ToRPCStatus() *status.Status {
621+
// GRPCStatus converts the error into a *status.Status
622+
func (e *FailedDownloadError) GRPCStatus() *status.Status {
623623
return status.New(codes.Internal, e.Error())
624624
}
625625

@@ -637,8 +637,8 @@ func (e *FailedUploadError) Unwrap() error {
637637
return e.Cause
638638
}
639639

640-
// ToRPCStatus converts the error into a *status.Status
641-
func (e *FailedUploadError) ToRPCStatus() *status.Status {
640+
// GRPCStatus converts the error into a *status.Status
641+
func (e *FailedUploadError) GRPCStatus() *status.Status {
642642
return status.New(codes.Internal, e.Error())
643643
}
644644

@@ -656,8 +656,8 @@ func (e *FailedDebugError) Unwrap() error {
656656
return e.Cause
657657
}
658658

659-
// ToRPCStatus converts the error into a *status.Status
660-
func (e *FailedDebugError) ToRPCStatus() *status.Status {
659+
// GRPCStatus converts the error into a *status.Status
660+
func (e *FailedDebugError) GRPCStatus() *status.Status {
661661
return status.New(codes.Internal, e.Error())
662662
}
663663

@@ -674,8 +674,8 @@ func (e *FailedMonitorError) Unwrap() error {
674674
return e.Cause
675675
}
676676

677-
// ToRPCStatus converts the error into a *status.Status
678-
func (e *FailedMonitorError) ToRPCStatus() *status.Status {
677+
// GRPCStatus converts the error into a *status.Status
678+
func (e *FailedMonitorError) GRPCStatus() *status.Status {
679679
return status.New(codes.Internal, e.Error())
680680
}
681681

@@ -693,8 +693,8 @@ func (e *CompileFailedError) Unwrap() error {
693693
return e.Cause
694694
}
695695

696-
// ToRPCStatus converts the error into a *status.Status
697-
func (e *CompileFailedError) ToRPCStatus() *status.Status {
696+
// GRPCStatus converts the error into a *status.Status
697+
func (e *CompileFailedError) GRPCStatus() *status.Status {
698698
return status.New(codes.Internal, e.Error())
699699
}
700700

@@ -712,8 +712,8 @@ func (e *InvalidArgumentError) Unwrap() error {
712712
return e.Cause
713713
}
714714

715-
// ToRPCStatus converts the error into a *status.Status
716-
func (e *InvalidArgumentError) ToRPCStatus() *status.Status {
715+
// GRPCStatus converts the error into a *status.Status
716+
func (e *InvalidArgumentError) GRPCStatus() *status.Status {
717717
return status.New(codes.InvalidArgument, e.Error())
718718
}
719719

@@ -731,8 +731,8 @@ func (e *NotFoundError) Unwrap() error {
731731
return e.Cause
732732
}
733733

734-
// ToRPCStatus converts the error into a *status.Status
735-
func (e *NotFoundError) ToRPCStatus() *status.Status {
734+
// GRPCStatus converts the error into a *status.Status
735+
func (e *NotFoundError) GRPCStatus() *status.Status {
736736
return status.New(codes.NotFound, e.Error())
737737
}
738738

@@ -750,8 +750,8 @@ func (e *PermissionDeniedError) Unwrap() error {
750750
return e.Cause
751751
}
752752

753-
// ToRPCStatus converts the error into a *status.Status
754-
func (e *PermissionDeniedError) ToRPCStatus() *status.Status {
753+
// GRPCStatus converts the error into a *status.Status
754+
func (e *PermissionDeniedError) GRPCStatus() *status.Status {
755755
return status.New(codes.PermissionDenied, e.Error())
756756
}
757757

@@ -769,8 +769,8 @@ func (e *UnavailableError) Unwrap() error {
769769
return e.Cause
770770
}
771771

772-
// ToRPCStatus converts the error into a *status.Status
773-
func (e *UnavailableError) ToRPCStatus() *status.Status {
772+
// GRPCStatus converts the error into a *status.Status
773+
func (e *UnavailableError) GRPCStatus() *status.Status {
774774
return status.New(codes.Unavailable, e.Error())
775775
}
776776

@@ -787,8 +787,8 @@ func (e *TempDirCreationFailedError) Unwrap() error {
787787
return e.Cause
788788
}
789789

790-
// ToRPCStatus converts the error into a *status.Status
791-
func (e *TempDirCreationFailedError) ToRPCStatus() *status.Status {
790+
// GRPCStatus converts the error into a *status.Status
791+
func (e *TempDirCreationFailedError) GRPCStatus() *status.Status {
792792
return status.New(codes.Unavailable, e.Error())
793793
}
794794

@@ -805,8 +805,8 @@ func (e *TempFileCreationFailedError) Unwrap() error {
805805
return e.Cause
806806
}
807807

808-
// ToRPCStatus converts the error into a *status.Status
809-
func (e *TempFileCreationFailedError) ToRPCStatus() *status.Status {
808+
// GRPCStatus converts the error into a *status.Status
809+
func (e *TempFileCreationFailedError) GRPCStatus() *status.Status {
810810
return status.New(codes.Unavailable, e.Error())
811811
}
812812

@@ -824,8 +824,8 @@ func (e *SignatureVerificationFailedError) Unwrap() error {
824824
return e.Cause
825825
}
826826

827-
// ToRPCStatus converts the error into a *status.Status
828-
func (e *SignatureVerificationFailedError) ToRPCStatus() *status.Status {
827+
// GRPCStatus converts the error into a *status.Status
828+
func (e *SignatureVerificationFailedError) GRPCStatus() *status.Status {
829829
return status.New(codes.Unavailable, e.Error())
830830
}
831831

@@ -842,8 +842,8 @@ func (e *MultiplePlatformsError) Error() string {
842842
len(e.Platforms), e.UserPlatform, strings.Join(e.Platforms, ", "))
843843
}
844844

845-
// ToRPCStatus converts the error into a *status.Status
846-
func (e *MultiplePlatformsError) ToRPCStatus() *status.Status {
845+
// GRPCStatus converts the error into a *status.Status
846+
func (e *MultiplePlatformsError) GRPCStatus() *status.Status {
847847
return status.New(codes.InvalidArgument, e.Error())
848848
}
849849

@@ -865,8 +865,8 @@ func (e *MultipleLibraryInstallDetected) Error() string {
865865
return res
866866
}
867867

868-
// ToRPCStatus converts the error into a *status.Status
869-
func (e *MultipleLibraryInstallDetected) ToRPCStatus() *status.Status {
868+
// GRPCStatus converts the error into a *status.Status
869+
func (e *MultipleLibraryInstallDetected) GRPCStatus() *status.Status {
870870
return status.New(codes.InvalidArgument, e.Error())
871871
}
872872

@@ -878,8 +878,8 @@ func (e *InstanceNeedsReinitialization) Error() string {
878878
return tr("The instance is no longer valid and needs to be reinitialized")
879879
}
880880

881-
// ToRPCStatus converts the error into a *status.Status
882-
func (e *InstanceNeedsReinitialization) ToRPCStatus() *status.Status {
881+
// GRPCStatus converts the error into a *status.Status
882+
func (e *InstanceNeedsReinitialization) GRPCStatus() *status.Status {
883883
st, _ := status.
884884
New(codes.InvalidArgument, e.Error()).
885885
WithDetails(&rpc.InstanceNeedsReinitializationError{})

‎commands/instances.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
160160
Cause: fmt.Errorf(tr("Invalid additional URL: %v", err)),
161161
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_INVALID_INDEX_URL,
162162
}
163-
responseError(e.ToRPCStatus())
163+
responseError(e.GRPCStatus())
164164
continue
165165
}
166166
allPackageIndexUrls = append(allPackageIndexUrls, URL)
@@ -172,7 +172,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
172172
Cause: err,
173173
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_INDEX_DOWNLOAD_ERROR,
174174
}
175-
responseError(e.ToRPCStatus())
175+
responseError(e.GRPCStatus())
176176
}
177177

178178
{
@@ -197,7 +197,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
197197
Cause: fmt.Errorf(tr("Loading index file: %v", err)),
198198
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_INDEX_LOAD_ERROR,
199199
}
200-
responseError(e.ToRPCStatus())
200+
responseError(e.GRPCStatus())
201201
}
202202
continue
203203
}
@@ -208,7 +208,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
208208
Cause: fmt.Errorf(tr("Loading index file: %v", err)),
209209
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_INDEX_LOAD_ERROR,
210210
}
211-
responseError(e.ToRPCStatus())
211+
responseError(e.GRPCStatus())
212212
}
213213
}
214214

@@ -221,7 +221,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
221221
if profile == nil {
222222
for _, err := range pmb.LoadHardware() {
223223
s := &cmderrors.PlatformLoadingError{Cause: err}
224-
responseError(s.ToRPCStatus())
224+
responseError(s.GRPCStatus())
225225
}
226226
} else {
227227
// Load platforms from profile
@@ -230,7 +230,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
230230
)
231231
for _, err := range errs {
232232
s := &cmderrors.PlatformLoadingError{Cause: err}
233-
responseError(s.ToRPCStatus())
233+
responseError(s.GRPCStatus())
234234
}
235235

236236
// Load "builtin" tools
@@ -250,7 +250,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
250250
Cause: fmt.Errorf(tr("can't find latest release of tool %s", name)),
251251
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_TOOL_LOAD_ERROR,
252252
}
253-
responseError(e.ToRPCStatus())
253+
responseError(e.GRPCStatus())
254254
} else if !latest.IsInstalled() {
255255
builtinToolsToInstall = append(builtinToolsToInstall, latest)
256256
}
@@ -265,15 +265,15 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
265265
Cause: err,
266266
Reason: rpc.FailedInstanceInitReason_FAILED_INSTANCE_INIT_REASON_TOOL_LOAD_ERROR,
267267
}
268-
responseError(e.ToRPCStatus())
268+
responseError(e.GRPCStatus())
269269
}
270270
}
271271

272272
// We installed at least one builtin tool after loading hardware
273273
// so we must reload again otherwise we would never found them.
274274
for _, err := range loadBuiltinTools() {
275275
s := &cmderrors.PlatformLoadingError{Cause: err}
276-
responseError(s.ToRPCStatus())
276+
responseError(s.GRPCStatus())
277277
}
278278
}
279279

@@ -288,7 +288,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
288288

289289
for _, err := range pme.LoadDiscoveries() {
290290
s := &cmderrors.PlatformLoadingError{Cause: err}
291-
responseError(s.ToRPCStatus())
291+
responseError(s.GRPCStatus())
292292
}
293293

294294
// Create library manager and add libraries directories
@@ -351,13 +351,13 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
351351
if err != nil {
352352
taskCallback(&rpc.TaskProgress{Name: tr("Library %s not found", libraryRef)})
353353
err := &cmderrors.LibraryNotFoundError{Library: libraryRef.Library}
354-
responseError(err.ToRPCStatus())
354+
responseError(err.GRPCStatus())
355355
continue
356356
}
357357
if err := libRelease.Resource.Download(pme.DownloadDir, nil, libRelease.String(), downloadCallback, ""); err != nil {
358358
taskCallback(&rpc.TaskProgress{Name: tr("Error downloading library %s", libraryRef)})
359359
e := &cmderrors.FailedLibraryInstallError{Cause: err}
360-
responseError(e.ToRPCStatus())
360+
responseError(e.GRPCStatus())
361361
continue
362362
}
363363
taskCallback(&rpc.TaskProgress{Completed: true})
@@ -367,7 +367,7 @@ func Init(req *rpc.InitRequest, responseCallback func(r *rpc.InitResponse)) erro
367367
if err := libRelease.Resource.Install(pme.DownloadDir, libRoot, libDir); err != nil {
368368
taskCallback(&rpc.TaskProgress{Name: tr("Error installing library %s", libraryRef)})
369369
e := &cmderrors.FailedLibraryInstallError{Cause: err}
370-
responseError(e.ToRPCStatus())
370+
responseError(e.GRPCStatus())
371371
continue
372372
}
373373
taskCallback(&rpc.TaskProgress{Completed: true})

‎commands/service.go

Lines changed: 36 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,16 @@ type ArduinoCoreServerImpl struct {
3636
VersionString string
3737
}
3838

39-
func convertErrorToRPCStatus(err error) error {
40-
if err == nil {
41-
return nil
42-
}
43-
if cmdErr, ok := err.(cmderrors.CommandError); ok {
44-
return cmdErr.ToRPCStatus().Err()
45-
}
46-
return err
47-
}
48-
4939
// BoardDetails FIXMEDOC
5040
func (s *ArduinoCoreServerImpl) BoardDetails(ctx context.Context, req *rpc.BoardDetailsRequest) (*rpc.BoardDetailsResponse, error) {
51-
resp, err := BoardDetails(ctx, req)
52-
return resp, convertErrorToRPCStatus(err)
41+
return BoardDetails(ctx, req)
5342
}
5443

5544
// BoardList FIXMEDOC
5645
func (s *ArduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardListRequest) (*rpc.BoardListResponse, error) {
5746
ports, _, err := BoardList(req)
5847
if err != nil {
59-
return nil, convertErrorToRPCStatus(err)
48+
return nil, err
6049
}
6150
return &rpc.BoardListResponse{
6251
Ports: ports,
@@ -65,14 +54,12 @@ func (s *ArduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis
6554

6655
// BoardListAll FIXMEDOC
6756
func (s *ArduinoCoreServerImpl) BoardListAll(ctx context.Context, req *rpc.BoardListAllRequest) (*rpc.BoardListAllResponse, error) {
68-
resp, err := BoardListAll(ctx, req)
69-
return resp, convertErrorToRPCStatus(err)
57+
return BoardListAll(ctx, req)
7058
}
7159

7260
// BoardSearch exposes to the gRPC interface the board search command
7361
func (s *ArduinoCoreServerImpl) BoardSearch(ctx context.Context, req *rpc.BoardSearchRequest) (*rpc.BoardSearchResponse, error) {
74-
resp, err := BoardSearch(ctx, req)
75-
return resp, convertErrorToRPCStatus(err)
62+
return BoardSearch(ctx, req)
7663
}
7764

7865
// BoardListWatch FIXMEDOC
@@ -89,7 +76,7 @@ func (s *ArduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s
8976

9077
eventsChan, err := BoardListWatch(stream.Context(), req)
9178
if err != nil {
92-
return convertErrorToRPCStatus(err)
79+
return err
9380
}
9481

9582
for event := range eventsChan {
@@ -103,26 +90,23 @@ func (s *ArduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s
10390

10491
// Destroy FIXMEDOC
10592
func (s *ArduinoCoreServerImpl) Destroy(ctx context.Context, req *rpc.DestroyRequest) (*rpc.DestroyResponse, error) {
106-
resp, err := Destroy(ctx, req)
107-
return resp, convertErrorToRPCStatus(err)
93+
return Destroy(ctx, req)
10894
}
10995

11096
// UpdateIndex FIXMEDOC
11197
func (s *ArduinoCoreServerImpl) UpdateIndex(req *rpc.UpdateIndexRequest, stream rpc.ArduinoCoreService_UpdateIndexServer) error {
11298
syncSend := NewSynchronizedSend(stream.Send)
113-
err := UpdateIndex(stream.Context(), req,
99+
return UpdateIndex(stream.Context(), req,
114100
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.UpdateIndexResponse{DownloadProgress: p}) },
115101
)
116-
return convertErrorToRPCStatus(err)
117102
}
118103

119104
// UpdateLibrariesIndex FIXMEDOC
120105
func (s *ArduinoCoreServerImpl) UpdateLibrariesIndex(req *rpc.UpdateLibrariesIndexRequest, stream rpc.ArduinoCoreService_UpdateLibrariesIndexServer) error {
121106
syncSend := NewSynchronizedSend(stream.Send)
122-
err := UpdateLibrariesIndex(stream.Context(), req,
107+
return UpdateLibrariesIndex(stream.Context(), req,
123108
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.UpdateLibrariesIndexResponse{DownloadProgress: p}) },
124109
)
125-
return convertErrorToRPCStatus(err)
126110
}
127111

128112
// Create FIXMEDOC
@@ -134,15 +118,13 @@ func (s *ArduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
134118
if len(userAgent) == 0 {
135119
userAgent = []string{"gRPCClientUnknown/0.0.0"}
136120
}
137-
res, err := Create(req, userAgent...)
138-
return res, convertErrorToRPCStatus(err)
121+
return Create(req, userAgent...)
139122
}
140123

141124
// Init FIXMEDOC
142125
func (s *ArduinoCoreServerImpl) Init(req *rpc.InitRequest, stream rpc.ArduinoCoreService_InitServer) error {
143126
syncSend := NewSynchronizedSend(stream.Send)
144-
err := Init(req, func(message *rpc.InitResponse) { syncSend.Send(message) })
145-
return convertErrorToRPCStatus(err)
127+
return Init(req, func(message *rpc.InitResponse) { syncSend.Send(message) })
146128
}
147129

148130
// Version FIXMEDOC
@@ -152,20 +134,18 @@ func (s *ArduinoCoreServerImpl) Version(ctx context.Context, req *rpc.VersionReq
152134

153135
// NewSketch FIXMEDOC
154136
func (s *ArduinoCoreServerImpl) NewSketch(ctx context.Context, req *rpc.NewSketchRequest) (*rpc.NewSketchResponse, error) {
155-
resp, err := NewSketch(ctx, req)
156-
return resp, convertErrorToRPCStatus(err)
137+
return NewSketch(ctx, req)
157138
}
158139

159140
// LoadSketch FIXMEDOC
160141
func (s *ArduinoCoreServerImpl) LoadSketch(ctx context.Context, req *rpc.LoadSketchRequest) (*rpc.LoadSketchResponse, error) {
161142
resp, err := LoadSketch(ctx, req)
162-
return &rpc.LoadSketchResponse{Sketch: resp}, convertErrorToRPCStatus(err)
143+
return &rpc.LoadSketchResponse{Sketch: resp}, err
163144
}
164145

165146
// SetSketchDefaults FIXMEDOC
166147
func (s *ArduinoCoreServerImpl) SetSketchDefaults(ctx context.Context, req *rpc.SetSketchDefaultsRequest) (*rpc.SetSketchDefaultsResponse, error) {
167-
resp, err := SetSketchDefaults(ctx, req)
168-
return resp, convertErrorToRPCStatus(err)
148+
return SetSketchDefaults(ctx, req)
169149
}
170150

171151
// Compile FIXMEDOC
@@ -198,7 +178,7 @@ func (s *ArduinoCoreServerImpl) Compile(req *rpc.CompileRequest, stream rpc.Ardu
198178
})
199179
}
200180
if compileErr != nil {
201-
return convertErrorToRPCStatus(compileErr)
181+
return compileErr
202182
}
203183
return compileRespSendErr
204184
}
@@ -212,7 +192,7 @@ func (s *ArduinoCoreServerImpl) PlatformInstall(req *rpc.PlatformInstallRequest,
212192
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.PlatformInstallResponse{TaskProgress: p}) },
213193
)
214194
if err != nil {
215-
return convertErrorToRPCStatus(err)
195+
return err
216196
}
217197
return syncSend.Send(resp)
218198
}
@@ -225,7 +205,7 @@ func (s *ArduinoCoreServerImpl) PlatformDownload(req *rpc.PlatformDownloadReques
225205
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.PlatformDownloadResponse{Progress: p}) },
226206
)
227207
if err != nil {
228-
return convertErrorToRPCStatus(err)
208+
return err
229209
}
230210
return syncSend.Send(resp)
231211
}
@@ -238,7 +218,7 @@ func (s *ArduinoCoreServerImpl) PlatformUninstall(req *rpc.PlatformUninstallRequ
238218
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.PlatformUninstallResponse{TaskProgress: p}) },
239219
)
240220
if err != nil {
241-
return convertErrorToRPCStatus(err)
221+
return err
242222
}
243223
return syncSend.Send(resp)
244224
}
@@ -254,13 +234,12 @@ func (s *ArduinoCoreServerImpl) PlatformUpgrade(req *rpc.PlatformUpgradeRequest,
254234
if err2 := syncSend.Send(resp); err2 != nil {
255235
return err2
256236
}
257-
return convertErrorToRPCStatus(err)
237+
return err
258238
}
259239

260240
// PlatformSearch FIXMEDOC
261241
func (s *ArduinoCoreServerImpl) PlatformSearch(ctx context.Context, req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse, error) {
262-
resp, err := PlatformSearch(req)
263-
return resp, convertErrorToRPCStatus(err)
242+
return PlatformSearch(req)
264243
}
265244

266245
// Upload FIXMEDOC
@@ -286,7 +265,7 @@ func (s *ArduinoCoreServerImpl) Upload(req *rpc.UploadRequest, stream rpc.Arduin
286265
},
287266
})
288267
}
289-
return convertErrorToRPCStatus(err)
268+
return err
290269
}
291270

292271
// UploadUsingProgrammer FIXMEDOC
@@ -310,15 +289,14 @@ func (s *ArduinoCoreServerImpl) UploadUsingProgrammer(req *rpc.UploadUsingProgra
310289
outStream.Close()
311290
errStream.Close()
312291
if err != nil {
313-
return convertErrorToRPCStatus(err)
292+
return err
314293
}
315294
return nil
316295
}
317296

318297
// SupportedUserFields FIXMEDOC
319298
func (s *ArduinoCoreServerImpl) SupportedUserFields(ctx context.Context, req *rpc.SupportedUserFieldsRequest) (*rpc.SupportedUserFieldsResponse, error) {
320-
res, err := SupportedUserFields(ctx, req)
321-
return res, convertErrorToRPCStatus(err)
299+
return SupportedUserFields(ctx, req)
322300
}
323301

324302
// BurnBootloader FIXMEDOC
@@ -342,15 +320,14 @@ func (s *ArduinoCoreServerImpl) BurnBootloader(req *rpc.BurnBootloaderRequest, s
342320
outStream.Close()
343321
errStream.Close()
344322
if err != nil {
345-
return convertErrorToRPCStatus(err)
323+
return err
346324
}
347325
return syncSend.Send(resp)
348326
}
349327

350328
// ListProgrammersAvailableForUpload FIXMEDOC
351329
func (s *ArduinoCoreServerImpl) ListProgrammersAvailableForUpload(ctx context.Context, req *rpc.ListProgrammersAvailableForUploadRequest) (*rpc.ListProgrammersAvailableForUploadResponse, error) {
352-
resp, err := ListProgrammersAvailableForUpload(ctx, req)
353-
return resp, convertErrorToRPCStatus(err)
330+
return ListProgrammersAvailableForUpload(ctx, req)
354331
}
355332

356333
// LibraryDownload FIXMEDOC
@@ -361,100 +338,89 @@ func (s *ArduinoCoreServerImpl) LibraryDownload(req *rpc.LibraryDownloadRequest,
361338
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryDownloadResponse{Progress: p}) },
362339
)
363340
if err != nil {
364-
return convertErrorToRPCStatus(err)
341+
return err
365342
}
366343
return syncSend.Send(resp)
367344
}
368345

369346
// LibraryInstall FIXMEDOC
370347
func (s *ArduinoCoreServerImpl) LibraryInstall(req *rpc.LibraryInstallRequest, stream rpc.ArduinoCoreService_LibraryInstallServer) error {
371348
syncSend := NewSynchronizedSend(stream.Send)
372-
err := LibraryInstall(
349+
return LibraryInstall(
373350
stream.Context(), req,
374351
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryInstallResponse{Progress: p}) },
375352
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryInstallResponse{TaskProgress: p}) },
376353
)
377-
return convertErrorToRPCStatus(err)
378354
}
379355

380356
// LibraryUpgrade FIXMEDOC
381357
func (s *ArduinoCoreServerImpl) LibraryUpgrade(req *rpc.LibraryUpgradeRequest, stream rpc.ArduinoCoreService_LibraryUpgradeServer) error {
382358
syncSend := NewSynchronizedSend(stream.Send)
383-
err := LibraryUpgrade(
359+
return LibraryUpgrade(
384360
stream.Context(), req,
385361
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryUpgradeResponse{Progress: p}) },
386362
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUpgradeResponse{TaskProgress: p}) },
387363
)
388-
return convertErrorToRPCStatus(err)
389364
}
390365

391366
// LibraryUninstall FIXMEDOC
392367
func (s *ArduinoCoreServerImpl) LibraryUninstall(req *rpc.LibraryUninstallRequest, stream rpc.ArduinoCoreService_LibraryUninstallServer) error {
393368
syncSend := NewSynchronizedSend(stream.Send)
394-
err := LibraryUninstall(stream.Context(), req,
369+
return LibraryUninstall(stream.Context(), req,
395370
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUninstallResponse{TaskProgress: p}) },
396371
)
397-
return convertErrorToRPCStatus(err)
398372
}
399373

400374
// LibraryUpgradeAll FIXMEDOC
401375
func (s *ArduinoCoreServerImpl) LibraryUpgradeAll(req *rpc.LibraryUpgradeAllRequest, stream rpc.ArduinoCoreService_LibraryUpgradeAllServer) error {
402376
syncSend := NewSynchronizedSend(stream.Send)
403-
err := LibraryUpgradeAll(req,
377+
return LibraryUpgradeAll(req,
404378
func(p *rpc.DownloadProgress) { syncSend.Send(&rpc.LibraryUpgradeAllResponse{Progress: p}) },
405379
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.LibraryUpgradeAllResponse{TaskProgress: p}) },
406380
)
407-
return convertErrorToRPCStatus(err)
408381
}
409382

410383
// LibraryResolveDependencies FIXMEDOC
411384
func (s *ArduinoCoreServerImpl) LibraryResolveDependencies(ctx context.Context, req *rpc.LibraryResolveDependenciesRequest) (*rpc.LibraryResolveDependenciesResponse, error) {
412-
resp, err := LibraryResolveDependencies(ctx, req)
413-
return resp, convertErrorToRPCStatus(err)
385+
return LibraryResolveDependencies(ctx, req)
414386
}
415387

416388
// LibrarySearch FIXMEDOC
417389
func (s *ArduinoCoreServerImpl) LibrarySearch(ctx context.Context, req *rpc.LibrarySearchRequest) (*rpc.LibrarySearchResponse, error) {
418-
resp, err := LibrarySearch(ctx, req)
419-
return resp, convertErrorToRPCStatus(err)
390+
return LibrarySearch(ctx, req)
420391
}
421392

422393
// LibraryList FIXMEDOC
423394
func (s *ArduinoCoreServerImpl) LibraryList(ctx context.Context, req *rpc.LibraryListRequest) (*rpc.LibraryListResponse, error) {
424-
resp, err := LibraryList(ctx, req)
425-
return resp, convertErrorToRPCStatus(err)
395+
return LibraryList(ctx, req)
426396
}
427397

428398
// ArchiveSketch FIXMEDOC
429399
func (s *ArduinoCoreServerImpl) ArchiveSketch(ctx context.Context, req *rpc.ArchiveSketchRequest) (*rpc.ArchiveSketchResponse, error) {
430-
resp, err := ArchiveSketch(ctx, req)
431-
return resp, convertErrorToRPCStatus(err)
400+
return ArchiveSketch(ctx, req)
432401
}
433402

434403
// ZipLibraryInstall FIXMEDOC
435404
func (s *ArduinoCoreServerImpl) ZipLibraryInstall(req *rpc.ZipLibraryInstallRequest, stream rpc.ArduinoCoreService_ZipLibraryInstallServer) error {
436405
syncSend := NewSynchronizedSend(stream.Send)
437-
err := ZipLibraryInstall(
406+
return ZipLibraryInstall(
438407
stream.Context(), req,
439408
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.ZipLibraryInstallResponse{TaskProgress: p}) },
440409
)
441-
return convertErrorToRPCStatus(err)
442410
}
443411

444412
// GitLibraryInstall FIXMEDOC
445413
func (s *ArduinoCoreServerImpl) GitLibraryInstall(req *rpc.GitLibraryInstallRequest, stream rpc.ArduinoCoreService_GitLibraryInstallServer) error {
446414
syncSend := NewSynchronizedSend(stream.Send)
447-
err := GitLibraryInstall(
415+
return GitLibraryInstall(
448416
stream.Context(), req,
449417
func(p *rpc.TaskProgress) { syncSend.Send(&rpc.GitLibraryInstallResponse{TaskProgress: p}) },
450418
)
451-
return convertErrorToRPCStatus(err)
452419
}
453420

454421
// EnumerateMonitorPortSettings FIXMEDOC
455422
func (s *ArduinoCoreServerImpl) EnumerateMonitorPortSettings(ctx context.Context, req *rpc.EnumerateMonitorPortSettingsRequest) (*rpc.EnumerateMonitorPortSettingsResponse, error) {
456-
resp, err := EnumerateMonitorPortSettings(ctx, req)
457-
return resp, convertErrorToRPCStatus(err)
423+
return EnumerateMonitorPortSettings(ctx, req)
458424
}
459425

460426
// Monitor FIXMEDOC

‎commands/service_debug.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ func (s *ArduinoCoreServerImpl) Debug(stream rpc.ArduinoCoreService_DebugServer)
6262

6363
// GetDebugConfig return metadata about a debug session
6464
func (s *ArduinoCoreServerImpl) GetDebugConfig(ctx context.Context, req *rpc.GetDebugConfigRequest) (*rpc.GetDebugConfigResponse, error) {
65-
res, err := GetDebugConfig(ctx, req)
66-
return res, convertErrorToRPCStatus(err)
65+
return GetDebugConfig(ctx, req)
6766
}
6867

6968
// IsDebugSupported checks if debugging is supported for a given configuration
7069
func (s *ArduinoCoreServerImpl) IsDebugSupported(ctx context.Context, req *rpc.IsDebugSupportedRequest) (*rpc.IsDebugSupportedResponse, error) {
71-
res, err := IsDebugSupported(ctx, req)
72-
return res, convertErrorToRPCStatus(err)
70+
return IsDebugSupported(ctx, req)
7371
}

‎internal/integrationtest/daemon/daemon_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {
503503
require.NoError(t, err)
504504

505505
platform, upgradeError := analyzePlatformUpgradeClient(plUpgrade)
506-
require.ErrorIs(t, upgradeError, (&cmderrors.PlatformAlreadyAtTheLatestVersionError{Platform: "esp8266:esp8266"}).ToRPCStatus().Err())
506+
require.ErrorIs(t, upgradeError, (&cmderrors.PlatformAlreadyAtTheLatestVersionError{Platform: "esp8266:esp8266"}).GRPCStatus().Err())
507507
require.NotNil(t, platform)
508508
require.False(t, platform.GetMetadata().GetIndexed()) // the esp866 is not present in the additional-urls
509509
require.False(t, platform.GetRelease().GetMissingMetadata()) // install.json is present
@@ -528,7 +528,7 @@ func TestDaemonCoreUpgradePlatform(t *testing.T) {
528528
require.NoError(t, err)
529529

530530
platform, upgradeError := analyzePlatformUpgradeClient(plUpgrade)
531-
require.ErrorIs(t, upgradeError, (&cmderrors.PlatformAlreadyAtTheLatestVersionError{Platform: "esp8266:esp8266"}).ToRPCStatus().Err())
531+
require.ErrorIs(t, upgradeError, (&cmderrors.PlatformAlreadyAtTheLatestVersionError{Platform: "esp8266:esp8266"}).GRPCStatus().Err())
532532
require.NotNil(t, platform)
533533
require.False(t, platform.GetMetadata().GetIndexed()) // the esp866 is not present in the additional-urls
534534
require.True(t, platform.GetRelease().GetMissingMetadata()) // install.json is present

0 commit comments

Comments
 (0)
Please sign in to comment.