@@ -26,8 +26,6 @@ import (
26
26
"google.golang.org/grpc/status"
27
27
)
28
28
29
- var tr = i18n .Tr
30
-
31
29
func composeErrorMsg (msg string , cause error ) string {
32
30
if cause == nil {
33
31
return msg
@@ -45,7 +43,7 @@ type CommandError interface {
45
43
type InvalidInstanceError struct {}
46
44
47
45
func (e * InvalidInstanceError ) Error () string {
48
- return tr ("Invalid instance" )
46
+ return i18n . Tr ("Invalid instance" )
49
47
}
50
48
51
49
// GRPCStatus converts the error into a *status.Status
@@ -59,7 +57,7 @@ type InvalidFQBNError struct {
59
57
}
60
58
61
59
func (e * InvalidFQBNError ) Error () string {
62
- return composeErrorMsg (tr ("Invalid FQBN" ), e .Cause )
60
+ return composeErrorMsg (i18n . Tr ("Invalid FQBN" ), e .Cause )
63
61
}
64
62
65
63
// GRPCStatus converts the error into a *status.Status
@@ -77,7 +75,7 @@ type InvalidURLError struct {
77
75
}
78
76
79
77
func (e * InvalidURLError ) Error () string {
80
- return composeErrorMsg (tr ("Invalid URL" ), e .Cause )
78
+ return composeErrorMsg (i18n . Tr ("Invalid URL" ), e .Cause )
81
79
}
82
80
83
81
// GRPCStatus converts the error into a *status.Status
@@ -95,7 +93,7 @@ type InvalidLibraryError struct {
95
93
}
96
94
97
95
func (e * InvalidLibraryError ) Error () string {
98
- return composeErrorMsg (tr ("Invalid library" ), e .Cause )
96
+ return composeErrorMsg (i18n . Tr ("Invalid library" ), e .Cause )
99
97
}
100
98
101
99
// GRPCStatus converts the error into a *status.Status
@@ -113,7 +111,7 @@ type InvalidVersionError struct {
113
111
}
114
112
115
113
func (e * InvalidVersionError ) Error () string {
116
- return composeErrorMsg (tr ("Invalid version" ), e .Cause )
114
+ return composeErrorMsg (i18n . Tr ("Invalid version" ), e .Cause )
117
115
}
118
116
119
117
// GRPCStatus converts the error into a *status.Status
@@ -132,7 +130,7 @@ type NoBoardsDetectedError struct {
132
130
}
133
131
134
132
func (e * NoBoardsDetectedError ) Error () string {
135
- return tr (
133
+ return i18n . Tr (
136
134
"Please specify an FQBN. The board on port %[1]s with protocol %[2]s can't be identified" ,
137
135
e .Port .GetAddress (),
138
136
e .Port .GetProtocol (),
@@ -152,7 +150,7 @@ type MultipleBoardsDetectedError struct {
152
150
}
153
151
154
152
func (e * MultipleBoardsDetectedError ) Error () string {
155
- return tr (
153
+ return i18n . Tr (
156
154
"Please specify an FQBN. Multiple possible boards detected on port %[1]s with protocol %[2]s" ,
157
155
e .Port .GetAddress (),
158
156
e .Port .GetProtocol (),
@@ -168,7 +166,7 @@ func (e *MultipleBoardsDetectedError) GRPCStatus() *status.Status {
168
166
type MissingFQBNError struct {}
169
167
170
168
func (e * MissingFQBNError ) Error () string {
171
- return tr ("Missing FQBN (Fully Qualified Board Name)" )
169
+ return i18n . Tr ("Missing FQBN (Fully Qualified Board Name)" )
172
170
}
173
171
174
172
// GRPCStatus converts the error into a *status.Status
@@ -182,7 +180,7 @@ type UnknownFQBNError struct {
182
180
}
183
181
184
182
func (e * UnknownFQBNError ) Error () string {
185
- return composeErrorMsg (tr ("Unknown FQBN" ), e .Cause )
183
+ return composeErrorMsg (i18n . Tr ("Unknown FQBN" ), e .Cause )
186
184
}
187
185
188
186
func (e * UnknownFQBNError ) Unwrap () error {
@@ -201,7 +199,7 @@ type UnknownProfileError struct {
201
199
}
202
200
203
201
func (e * UnknownProfileError ) Error () string {
204
- return composeErrorMsg (tr ("Profile '%s' not found" , e .Profile ), e .Cause )
202
+ return composeErrorMsg (i18n . Tr ("Profile '%s' not found" , e .Profile ), e .Cause )
205
203
}
206
204
207
205
func (e * UnknownProfileError ) Unwrap () error {
@@ -219,7 +217,7 @@ type InvalidProfileError struct {
219
217
}
220
218
221
219
func (e * InvalidProfileError ) Error () string {
222
- return composeErrorMsg (tr ("Invalid profile" ), e .Cause )
220
+ return composeErrorMsg (i18n . Tr ("Invalid profile" ), e .Cause )
223
221
}
224
222
225
223
func (e * InvalidProfileError ) Unwrap () error {
@@ -235,7 +233,7 @@ func (e *InvalidProfileError) GRPCStatus() *status.Status {
235
233
type MissingPortAddressError struct {}
236
234
237
235
func (e * MissingPortAddressError ) Error () string {
238
- return tr ("Missing port address" )
236
+ return i18n . Tr ("Missing port address" )
239
237
}
240
238
241
239
// GRPCStatus converts the error into a *status.Status
@@ -247,7 +245,7 @@ func (e *MissingPortAddressError) GRPCStatus() *status.Status {
247
245
type MissingPortProtocolError struct {}
248
246
249
247
func (e * MissingPortProtocolError ) Error () string {
250
- return tr ("Missing port protocol" )
248
+ return i18n . Tr ("Missing port protocol" )
251
249
}
252
250
253
251
// GRPCStatus converts the error into a *status.Status
@@ -259,7 +257,7 @@ func (e *MissingPortProtocolError) GRPCStatus() *status.Status {
259
257
type MissingPortError struct {}
260
258
261
259
func (e * MissingPortError ) Error () string {
262
- return tr ("Missing port" )
260
+ return i18n . Tr ("Missing port" )
263
261
}
264
262
265
263
// GRPCStatus converts the error into a *status.Status
@@ -273,7 +271,7 @@ type NoMonitorAvailableForProtocolError struct {
273
271
}
274
272
275
273
func (e * NoMonitorAvailableForProtocolError ) Error () string {
276
- return tr ("No monitor available for the port protocol %s" , e .Protocol )
274
+ return i18n . Tr ("No monitor available for the port protocol %s" , e .Protocol )
277
275
}
278
276
279
277
// GRPCStatus converts the error into a *status.Status
@@ -285,7 +283,7 @@ func (e *NoMonitorAvailableForProtocolError) GRPCStatus() *status.Status {
285
283
type MissingProgrammerError struct {}
286
284
287
285
func (e * MissingProgrammerError ) Error () string {
288
- return tr ("Missing programmer" )
286
+ return i18n . Tr ("Missing programmer" )
289
287
}
290
288
291
289
// GRPCStatus converts the error into a *status.Status
@@ -298,7 +296,7 @@ func (e *MissingProgrammerError) GRPCStatus() *status.Status {
298
296
type ProgrammerRequiredForUploadError struct {}
299
297
300
298
func (e * ProgrammerRequiredForUploadError ) Error () string {
301
- return tr ("A programmer is required to upload" )
299
+ return i18n . Tr ("A programmer is required to upload" )
302
300
}
303
301
304
302
// GRPCStatus converts the error into a *status.Status
@@ -338,7 +336,7 @@ type ProgrammerNotFoundError struct {
338
336
}
339
337
340
338
func (e * ProgrammerNotFoundError ) Error () string {
341
- return composeErrorMsg (tr ("Programmer '%s' not found" , e .Programmer ), e .Cause )
339
+ return composeErrorMsg (i18n . Tr ("Programmer '%s' not found" , e .Programmer ), e .Cause )
342
340
}
343
341
344
342
func (e * ProgrammerNotFoundError ) Unwrap () error {
@@ -357,7 +355,7 @@ type MonitorNotFoundError struct {
357
355
}
358
356
359
357
func (e * MonitorNotFoundError ) Error () string {
360
- return composeErrorMsg (tr ("Monitor '%s' not found" , e .Monitor ), e .Cause )
358
+ return composeErrorMsg (i18n . Tr ("Monitor '%s' not found" , e .Monitor ), e .Cause )
361
359
}
362
360
363
361
func (e * MonitorNotFoundError ) Unwrap () error {
@@ -376,7 +374,7 @@ type InvalidPlatformPropertyError struct {
376
374
}
377
375
378
376
func (e * InvalidPlatformPropertyError ) Error () string {
379
- return tr ("Invalid '%[1]s' property: %[2]s" , e .Property , e .Value )
377
+ return i18n . Tr ("Invalid '%[1]s' property: %[2]s" , e .Property , e .Value )
380
378
}
381
379
382
380
// GRPCStatus converts the error into a *status.Status
@@ -390,7 +388,7 @@ type MissingPlatformPropertyError struct {
390
388
}
391
389
392
390
func (e * MissingPlatformPropertyError ) Error () string {
393
- return tr ("Property '%s' is undefined" , e .Property )
391
+ return i18n . Tr ("Property '%s' is undefined" , e .Property )
394
392
}
395
393
396
394
// GRPCStatus converts the error into a *status.Status
@@ -405,7 +403,7 @@ type PlatformNotFoundError struct {
405
403
}
406
404
407
405
func (e * PlatformNotFoundError ) Error () string {
408
- return composeErrorMsg (tr ("Platform '%s' not found" , e .Platform ), e .Cause )
406
+ return composeErrorMsg (i18n . Tr ("Platform '%s' not found" , e .Platform ), e .Cause )
409
407
}
410
408
411
409
// GRPCStatus converts the error into a *status.Status
@@ -423,7 +421,7 @@ type PlatformLoadingError struct {
423
421
}
424
422
425
423
func (e * PlatformLoadingError ) Error () string {
426
- return composeErrorMsg (tr ("Error loading hardware platform" ), e .Cause )
424
+ return composeErrorMsg (i18n . Tr ("Error loading hardware platform" ), e .Cause )
427
425
}
428
426
429
427
// GRPCStatus converts the error into a *status.Status
@@ -444,7 +442,7 @@ type LibraryNotFoundError struct {
444
442
}
445
443
446
444
func (e * LibraryNotFoundError ) Error () string {
447
- return composeErrorMsg (tr ("Library '%s' not found" , e .Library ), e .Cause )
445
+ return composeErrorMsg (i18n . Tr ("Library '%s' not found" , e .Library ), e .Cause )
448
446
}
449
447
450
448
// GRPCStatus converts the error into a *status.Status
@@ -463,7 +461,7 @@ type LibraryDependenciesResolutionFailedError struct {
463
461
}
464
462
465
463
func (e * LibraryDependenciesResolutionFailedError ) Error () string {
466
- return composeErrorMsg (tr ("No valid dependencies solution found" ), e .Cause )
464
+ return composeErrorMsg (i18n . Tr ("No valid dependencies solution found" ), e .Cause )
467
465
}
468
466
469
467
// GRPCStatus converts the error into a *status.Status
@@ -481,7 +479,7 @@ type PlatformAlreadyAtTheLatestVersionError struct {
481
479
}
482
480
483
481
func (e * PlatformAlreadyAtTheLatestVersionError ) Error () string {
484
- return tr ("Platform '%s' is already at the latest version" , e .Platform )
482
+ return i18n . Tr ("Platform '%s' is already at the latest version" , e .Platform )
485
483
}
486
484
487
485
// GRPCStatus converts the error into a *status.Status
@@ -496,7 +494,7 @@ func (e *PlatformAlreadyAtTheLatestVersionError) GRPCStatus() *status.Status {
496
494
type MissingSketchPathError struct {}
497
495
498
496
func (e * MissingSketchPathError ) Error () string {
499
- return tr ("Missing sketch path" )
497
+ return i18n . Tr ("Missing sketch path" )
500
498
}
501
499
502
500
// GRPCStatus converts the error into a *status.Status
@@ -510,7 +508,7 @@ type CantCreateSketchError struct {
510
508
}
511
509
512
510
func (e * CantCreateSketchError ) Error () string {
513
- return composeErrorMsg (tr ("Can't create sketch" ), e .Cause )
511
+ return composeErrorMsg (i18n . Tr ("Can't create sketch" ), e .Cause )
514
512
}
515
513
516
514
func (e * CantCreateSketchError ) Unwrap () error {
@@ -523,7 +521,7 @@ type CantUpdateSketchError struct {
523
521
}
524
522
525
523
func (e * CantUpdateSketchError ) Error () string {
526
- return composeErrorMsg (tr ("Can't update sketch" ), e .Cause )
524
+ return composeErrorMsg (i18n . Tr ("Can't update sketch" ), e .Cause )
527
525
}
528
526
529
527
func (e * CantUpdateSketchError ) Unwrap () error {
@@ -536,7 +534,7 @@ type CantOpenSketchError struct {
536
534
}
537
535
538
536
func (e * CantOpenSketchError ) Error () string {
539
- return composeErrorMsg (tr ("Can't open sketch" ), e .Cause )
537
+ return composeErrorMsg (i18n . Tr ("Can't open sketch" ), e .Cause )
540
538
}
541
539
542
540
func (e * CantOpenSketchError ) Unwrap () error {
@@ -573,7 +571,7 @@ type FailedLibraryInstallError struct {
573
571
}
574
572
575
573
func (e * FailedLibraryInstallError ) Error () string {
576
- return composeErrorMsg (tr ("Library install failed" ), e .Cause )
574
+ return composeErrorMsg (i18n . Tr ("Library install failed" ), e .Cause )
577
575
}
578
576
579
577
func (e * FailedLibraryInstallError ) Unwrap () error {
@@ -667,7 +665,7 @@ type FailedMonitorError struct {
667
665
}
668
666
669
667
func (e * FailedMonitorError ) Error () string {
670
- return composeErrorMsg (tr ("Port monitor error" ), e .Cause )
668
+ return composeErrorMsg (i18n . Tr ("Port monitor error" ), e .Cause )
671
669
}
672
670
673
671
func (e * FailedMonitorError ) Unwrap () error {
@@ -780,7 +778,7 @@ type TempDirCreationFailedError struct {
780
778
}
781
779
782
780
func (e * TempDirCreationFailedError ) Error () string {
783
- return composeErrorMsg (tr ("Cannot create temp dir" ), e .Cause )
781
+ return composeErrorMsg (i18n . Tr ("Cannot create temp dir" ), e .Cause )
784
782
}
785
783
786
784
func (e * TempDirCreationFailedError ) Unwrap () error {
@@ -798,7 +796,7 @@ type TempFileCreationFailedError struct {
798
796
}
799
797
800
798
func (e * TempFileCreationFailedError ) Error () string {
801
- return composeErrorMsg (tr ("Cannot create temp file" ), e .Cause )
799
+ return composeErrorMsg (i18n . Tr ("Cannot create temp file" ), e .Cause )
802
800
}
803
801
804
802
func (e * TempFileCreationFailedError ) Unwrap () error {
@@ -817,7 +815,7 @@ type SignatureVerificationFailedError struct {
817
815
}
818
816
819
817
func (e * SignatureVerificationFailedError ) Error () string {
820
- return composeErrorMsg (tr ("'%s' has an invalid signature" , e .File ), e .Cause )
818
+ return composeErrorMsg (i18n . Tr ("'%s' has an invalid signature" , e .File ), e .Cause )
821
819
}
822
820
823
821
func (e * SignatureVerificationFailedError ) Unwrap () error {
@@ -838,7 +836,7 @@ type MultiplePlatformsError struct {
838
836
}
839
837
840
838
func (e * MultiplePlatformsError ) Error () string {
841
- return tr ("Found %d platforms matching \" %s\" : %s" ,
839
+ return i18n . Tr ("Found %d platforms matching \" %s\" : %s" ,
842
840
len (e .Platforms ), e .UserPlatform , strings .Join (e .Platforms , ", " ))
843
841
}
844
842
@@ -857,7 +855,7 @@ type MultipleLibraryInstallDetected struct {
857
855
}
858
856
859
857
func (e * MultipleLibraryInstallDetected ) Error () string {
860
- res := tr ("The library %s has multiple installations:" , e .LibName ) + "\n "
858
+ res := i18n . Tr ("The library %s has multiple installations:" , e .LibName ) + "\n "
861
859
for _ , lib := range e .LibsDir {
862
860
res += fmt .Sprintf ("- %s\n " , lib )
863
861
}
@@ -875,7 +873,7 @@ type InstanceNeedsReinitialization struct {
875
873
}
876
874
877
875
func (e * InstanceNeedsReinitialization ) Error () string {
878
- return tr ("The instance is no longer valid and needs to be reinitialized" )
876
+ return i18n . Tr ("The instance is no longer valid and needs to be reinitialized" )
879
877
}
880
878
881
879
// GRPCStatus converts the error into a *status.Status
0 commit comments