@@ -32,6 +32,7 @@ func composeErrorMsg(msg string, cause error) string {
32
32
33
33
// CommandError is an error that may be converted into a gRPC status.
34
34
type CommandError interface {
35
+ // ToRPCStatus convertes the error into a *status.Status
35
36
ToRPCStatus () * status.Status
36
37
}
37
38
@@ -42,6 +43,7 @@ func (e *InvalidInstanceError) Error() string {
42
43
return tr ("Invalid instance" )
43
44
}
44
45
46
+ // ToRPCStatus convertes the error into a *status.Status
45
47
func (e * InvalidInstanceError ) ToRPCStatus () * status.Status {
46
48
return status .New (codes .InvalidArgument , e .Error ())
47
49
}
@@ -55,6 +57,7 @@ func (e *InvalidFQBNError) Error() string {
55
57
return composeErrorMsg (tr ("Invalid FQBN" ), e .Cause )
56
58
}
57
59
60
+ // ToRPCStatus convertes the error into a *status.Status
58
61
func (e * InvalidFQBNError ) ToRPCStatus () * status.Status {
59
62
return status .New (codes .InvalidArgument , e .Error ())
60
63
}
@@ -72,6 +75,7 @@ func (e *InvalidURLError) Error() string {
72
75
return composeErrorMsg (tr ("Invalid URL" ), e .Cause )
73
76
}
74
77
78
+ // ToRPCStatus convertes the error into a *status.Status
75
79
func (e * InvalidURLError ) ToRPCStatus () * status.Status {
76
80
return status .New (codes .InvalidArgument , e .Error ())
77
81
}
@@ -89,6 +93,7 @@ func (e *InvalidLibraryError) Error() string {
89
93
return composeErrorMsg (tr ("Invalid library" ), e .Cause )
90
94
}
91
95
96
+ // ToRPCStatus convertes the error into a *status.Status
92
97
func (e * InvalidLibraryError ) ToRPCStatus () * status.Status {
93
98
return status .New (codes .InvalidArgument , e .Error ())
94
99
}
@@ -106,6 +111,7 @@ func (e *InvalidVersionError) Error() string {
106
111
return composeErrorMsg (tr ("Invalid version" ), e .Cause )
107
112
}
108
113
114
+ // ToRPCStatus convertes the error into a *status.Status
109
115
func (e * InvalidVersionError ) ToRPCStatus () * status.Status {
110
116
return status .New (codes .InvalidArgument , e .Error ())
111
117
}
@@ -121,6 +127,7 @@ func (e *MissingFQBNError) Error() string {
121
127
return tr ("Missing FQBN (Fully Qualified Board Name)" )
122
128
}
123
129
130
+ // ToRPCStatus convertes the error into a *status.Status
124
131
func (e * MissingFQBNError ) ToRPCStatus () * status.Status {
125
132
return status .New (codes .InvalidArgument , e .Error ())
126
133
}
@@ -138,6 +145,7 @@ func (e *UnknownFQBNError) Unwrap() error {
138
145
return e .Cause
139
146
}
140
147
148
+ // ToRPCStatus convertes the error into a *status.Status
141
149
func (e * UnknownFQBNError ) ToRPCStatus () * status.Status {
142
150
return status .New (codes .NotFound , e .Error ())
143
151
}
@@ -149,6 +157,7 @@ func (e *MissingPortProtocolError) Error() string {
149
157
return tr ("Missing port protocol" )
150
158
}
151
159
160
+ // ToRPCStatus convertes the error into a *status.Status
152
161
func (e * MissingPortProtocolError ) ToRPCStatus () * status.Status {
153
162
return status .New (codes .InvalidArgument , e .Error ())
154
163
}
@@ -160,6 +169,7 @@ func (e *MissingProgrammerError) Error() string {
160
169
return tr ("Missing programmer" )
161
170
}
162
171
172
+ // ToRPCStatus convertes the error into a *status.Status
163
173
func (e * MissingProgrammerError ) ToRPCStatus () * status.Status {
164
174
return status .New (codes .InvalidArgument , e .Error ())
165
175
}
@@ -171,6 +181,7 @@ func (e *ProgreammerRequiredForUploadError) Error() string {
171
181
return tr ("A programmer is required to upload" )
172
182
}
173
183
184
+ // ToRPCStatus convertes the error into a *status.Status
174
185
func (e * ProgreammerRequiredForUploadError ) ToRPCStatus () * status.Status {
175
186
st , _ := status .
176
187
New (codes .InvalidArgument , e .Error ()).
@@ -192,6 +203,7 @@ func (e *ProgrammerNotFoundError) Unwrap() error {
192
203
return e .Cause
193
204
}
194
205
206
+ // ToRPCStatus convertes the error into a *status.Status
195
207
func (e * ProgrammerNotFoundError ) ToRPCStatus () * status.Status {
196
208
return status .New (codes .NotFound , e .Error ())
197
209
}
@@ -206,6 +218,7 @@ func (e *InvalidPlatformPropertyError) Error() string {
206
218
return tr ("Invalid '%[1]s' property: %[2]s" , e .Property , e .Value )
207
219
}
208
220
221
+ // ToRPCStatus convertes the error into a *status.Status
209
222
func (e * InvalidPlatformPropertyError ) ToRPCStatus () * status.Status {
210
223
return status .New (codes .FailedPrecondition , e .Error ())
211
224
}
@@ -219,6 +232,7 @@ func (e *MissingPlatformPropertyError) Error() string {
219
232
return tr ("Property '%s' is undefined" , e .Property )
220
233
}
221
234
235
+ // ToRPCStatus convertes the error into a *status.Status
222
236
func (e * MissingPlatformPropertyError ) ToRPCStatus () * status.Status {
223
237
return status .New (codes .FailedPrecondition , e .Error ())
224
238
}
@@ -233,6 +247,7 @@ func (e *PlatformNotFound) Error() string {
233
247
return composeErrorMsg (tr ("Platform '%s' not found" , e .Platform ), e .Cause )
234
248
}
235
249
250
+ // ToRPCStatus convertes the error into a *status.Status
236
251
func (e * PlatformNotFound ) ToRPCStatus () * status.Status {
237
252
return status .New (codes .FailedPrecondition , e .Error ())
238
253
}
@@ -251,6 +266,7 @@ func (e *LibraryNotFound) Error() string {
251
266
return composeErrorMsg (tr ("Library '%s' not found" , e .Library ), e .Cause )
252
267
}
253
268
269
+ // ToRPCStatus convertes the error into a *status.Status
254
270
func (e * LibraryNotFound ) ToRPCStatus () * status.Status {
255
271
return status .New (codes .FailedPrecondition , e .Error ())
256
272
}
@@ -269,6 +285,7 @@ func (e *LibraryDependenciesResolutionFailedError) Error() string {
269
285
return composeErrorMsg (tr ("No valid dependencies solution found" ), e .Cause )
270
286
}
271
287
288
+ // ToRPCStatus convertes the error into a *status.Status
272
289
func (e * LibraryDependenciesResolutionFailedError ) ToRPCStatus () * status.Status {
273
290
return status .New (codes .FailedPrecondition , e .Error ())
274
291
}
@@ -286,6 +303,7 @@ func (e *PlatformAlreadyAtTheLatestVersionError) Error() string {
286
303
return tr ("Platform '%s' is already at the latest version" , e .Platform )
287
304
}
288
305
306
+ // ToRPCStatus convertes the error into a *status.Status
289
307
func (e * PlatformAlreadyAtTheLatestVersionError ) ToRPCStatus () * status.Status {
290
308
st , _ := status .
291
309
New (codes .AlreadyExists , e .Error ()).
@@ -300,6 +318,7 @@ func (e *MissingSketchPathError) Error() string {
300
318
return tr ("Missing sketch path" )
301
319
}
302
320
321
+ // ToRPCStatus convertes the error into a *status.Status
303
322
func (e * MissingSketchPathError ) ToRPCStatus () * status.Status {
304
323
return status .New (codes .InvalidArgument , e .Error ())
305
324
}
@@ -317,6 +336,7 @@ func (e *CantOpenSketchError) Unwrap() error {
317
336
return e .Cause
318
337
}
319
338
339
+ // ToRPCStatus convertes the error into a *status.Status
320
340
func (e * CantOpenSketchError ) ToRPCStatus () * status.Status {
321
341
return status .New (codes .NotFound , e .Error ())
322
342
}
@@ -335,6 +355,7 @@ func (e *FailedInstallError) Unwrap() error {
335
355
return e .Cause
336
356
}
337
357
358
+ // ToRPCStatus convertes the error into a *status.Status
338
359
func (e * FailedInstallError ) ToRPCStatus () * status.Status {
339
360
return status .New (codes .Internal , e .Error ())
340
361
}
@@ -352,6 +373,7 @@ func (e *FailedLibraryInstallError) Unwrap() error {
352
373
return e .Cause
353
374
}
354
375
376
+ // ToRPCStatus convertes the error into a *status.Status
355
377
func (e * FailedLibraryInstallError ) ToRPCStatus () * status.Status {
356
378
return status .New (codes .Internal , e .Error ())
357
379
}
@@ -370,6 +392,7 @@ func (e *FailedUninstallError) Unwrap() error {
370
392
return e .Cause
371
393
}
372
394
395
+ // ToRPCStatus convertes the error into a *status.Status
373
396
func (e * FailedUninstallError ) ToRPCStatus () * status.Status {
374
397
return status .New (codes .Internal , e .Error ())
375
398
}
@@ -388,6 +411,7 @@ func (e *FailedDownloadError) Unwrap() error {
388
411
return e .Cause
389
412
}
390
413
414
+ // ToRPCStatus convertes the error into a *status.Status
391
415
func (e * FailedDownloadError ) ToRPCStatus () * status.Status {
392
416
return status .New (codes .Internal , e .Error ())
393
417
}
@@ -406,6 +430,7 @@ func (e *FailedUploadError) Unwrap() error {
406
430
return e .Cause
407
431
}
408
432
433
+ // ToRPCStatus convertes the error into a *status.Status
409
434
func (e * FailedUploadError ) ToRPCStatus () * status.Status {
410
435
return status .New (codes .Internal , e .Error ())
411
436
}
@@ -424,6 +449,7 @@ func (e *FailedDebugError) Unwrap() error {
424
449
return e .Cause
425
450
}
426
451
452
+ // ToRPCStatus convertes the error into a *status.Status
427
453
func (e * FailedDebugError ) ToRPCStatus () * status.Status {
428
454
return status .New (codes .Internal , e .Error ())
429
455
}
@@ -442,6 +468,7 @@ func (e *CompileFailedError) Unwrap() error {
442
468
return e .Cause
443
469
}
444
470
471
+ // ToRPCStatus convertes the error into a *status.Status
445
472
func (e * CompileFailedError ) ToRPCStatus () * status.Status {
446
473
return status .New (codes .Internal , e .Error ())
447
474
}
@@ -460,6 +487,7 @@ func (e *InvalidArgumentError) Unwrap() error {
460
487
return e .Cause
461
488
}
462
489
490
+ // ToRPCStatus convertes the error into a *status.Status
463
491
func (e * InvalidArgumentError ) ToRPCStatus () * status.Status {
464
492
return status .New (codes .InvalidArgument , e .Error ())
465
493
}
@@ -478,6 +506,7 @@ func (e *NotFoundError) Unwrap() error {
478
506
return e .Cause
479
507
}
480
508
509
+ // ToRPCStatus convertes the error into a *status.Status
481
510
func (e * NotFoundError ) ToRPCStatus () * status.Status {
482
511
return status .New (codes .NotFound , e .Error ())
483
512
}
@@ -496,6 +525,7 @@ func (e *PermissionDeniedError) Unwrap() error {
496
525
return e .Cause
497
526
}
498
527
528
+ // ToRPCStatus convertes the error into a *status.Status
499
529
func (e * PermissionDeniedError ) ToRPCStatus () * status.Status {
500
530
return status .New (codes .PermissionDenied , e .Error ())
501
531
}
@@ -514,6 +544,7 @@ func (e *UnavailableError) Unwrap() error {
514
544
return e .Cause
515
545
}
516
546
547
+ // ToRPCStatus convertes the error into a *status.Status
517
548
func (e * UnavailableError ) ToRPCStatus () * status.Status {
518
549
return status .New (codes .Unavailable , e .Error ())
519
550
}
@@ -531,6 +562,7 @@ func (e *TempDirCreationFailedError) Unwrap() error {
531
562
return e .Cause
532
563
}
533
564
565
+ // ToRPCStatus convertes the error into a *status.Status
534
566
func (e * TempDirCreationFailedError ) ToRPCStatus () * status.Status {
535
567
return status .New (codes .Unavailable , e .Error ())
536
568
}
@@ -548,6 +580,7 @@ func (e *TempFileCreationFailedError) Unwrap() error {
548
580
return e .Cause
549
581
}
550
582
583
+ // ToRPCStatus convertes the error into a *status.Status
551
584
func (e * TempFileCreationFailedError ) ToRPCStatus () * status.Status {
552
585
return status .New (codes .Unavailable , e .Error ())
553
586
}
@@ -566,6 +599,7 @@ func (e *SignatureVerificationFailedError) Unwrap() error {
566
599
return e .Cause
567
600
}
568
601
602
+ // ToRPCStatus convertes the error into a *status.Status
569
603
func (e * SignatureVerificationFailedError ) ToRPCStatus () * status.Status {
570
604
return status .New (codes .Unavailable , e .Error ())
571
605
}
0 commit comments