forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
1047 lines (873 loc) · 32.1 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2016 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package libkbfs
import (
"fmt"
"time"
"github.com/keybase/client/go/kbfs/data"
"github.com/keybase/client/go/kbfs/idutil"
"github.com/keybase/client/go/kbfs/kbfsblock"
"github.com/keybase/client/go/kbfs/kbfscrypto"
"github.com/keybase/client/go/kbfs/kbfsmd"
"github.com/keybase/client/go/kbfs/tlf"
"github.com/keybase/client/go/kbfs/tlfhandle"
kbname "github.com/keybase/client/go/kbun"
"github.com/keybase/client/go/protocol/keybase1"
)
// ErrorFile is the name of the virtual file in KBFS that should
// contain the last reported error(s).
var ErrorFile = ".kbfs_error"
// WrapError simply wraps an error in a fmt.Stringer interface, so
// that it can be reported.
type WrapError struct {
Err error
}
// String implements the fmt.Stringer interface for WrapError
func (e WrapError) String() string {
return e.Err.Error()
}
// InvalidBlockRefError indicates an invalid block reference was
// encountered.
type InvalidBlockRefError struct {
ref data.BlockRef
}
func (e InvalidBlockRefError) Error() string {
return fmt.Sprintf("Invalid block ref %s", e.ref)
}
// InvalidPathError indicates an invalid path was encountered.
type InvalidPathError struct {
p data.Path
}
// Error implements the error interface for InvalidPathError.
func (e InvalidPathError) Error() string {
return fmt.Sprintf("Invalid path %s", e.p.DebugString())
}
// InvalidParentPathError indicates a path without a valid parent was
// encountered.
type InvalidParentPathError struct {
p data.Path
}
// Error implements the error interface for InvalidParentPathError.
func (e InvalidParentPathError) Error() string {
return fmt.Sprintf("Path with invalid parent %s", e.p.DebugString())
}
// DirNotEmptyError indicates that the user tried to unlink a
// subdirectory that was not empty.
type DirNotEmptyError struct {
Name data.PathPartString
}
// Error implements the error interface for DirNotEmptyError
func (e DirNotEmptyError) Error() string {
return fmt.Sprintf("Directory %s is not empty and can't be removed", e.Name)
}
// TlfAccessError that the user tried to perform an unpermitted
// operation on a top-level folder.
type TlfAccessError struct {
ID tlf.ID
}
// Error implements the error interface for TlfAccessError
func (e TlfAccessError) Error() string {
return fmt.Sprintf("Operation not permitted on folder %s", e.ID)
}
// RenameAcrossDirsError indicates that the user tried to do an atomic
// rename across directories.
type RenameAcrossDirsError struct {
// ApplicationExecPath, if not empty, is the exec path of the application
// that issued the rename.
ApplicationExecPath string
}
// Error implements the error interface for RenameAcrossDirsError
func (e RenameAcrossDirsError) Error() string {
return fmt.Sprintf("Cannot rename across directories")
}
// ErrorFileAccessError indicates that the user tried to perform an
// operation on the ErrorFile that is not allowed.
type ErrorFileAccessError struct {
}
// Error implements the error interface for ErrorFileAccessError
func (e ErrorFileAccessError) Error() string {
return fmt.Sprintf("Operation not allowed on file %s", ErrorFile)
}
// WriteUnsupportedError indicates an error when trying to write a file
type WriteUnsupportedError struct {
Filename string
}
// Error implements the error interface for WriteUnsupportedError
func (e WriteUnsupportedError) Error() string {
return fmt.Sprintf("Writing to %s is unsupported", e.Filename)
}
// WriteToReadonlyNodeError indicates an error when trying to write a
// node that's marked as read-only.
type WriteToReadonlyNodeError struct {
Filename string
}
// Error implements the error interface for WriteToReadonlyNodeError
func (e WriteToReadonlyNodeError) Error() string {
return fmt.Sprintf("%s is read-only and writes are not allowed", e.Filename)
}
// UnsupportedOpInUnlinkedDirError indicates an error when trying to
// create a file.
type UnsupportedOpInUnlinkedDirError struct {
Dirpath string
}
// Error implements the error interface for UnsupportedOpInUnlinkedDirError.
func (e UnsupportedOpInUnlinkedDirError) Error() string {
return fmt.Sprintf(
"Operation is unsupported in unlinked directory %s", e.Dirpath)
}
// NewWriteUnsupportedError returns unsupported error trying to write a file
func NewWriteUnsupportedError(filename string) error {
return WriteUnsupportedError{
Filename: filename,
}
}
// NeedSelfRekeyError indicates that the folder in question needs to
// be rekeyed for the local device, and can be done so by one of the
// other user's devices.
type NeedSelfRekeyError struct {
Tlf tlf.CanonicalName
Err error
}
// Error implements the error interface for NeedSelfRekeyError
func (e NeedSelfRekeyError) Error() string {
return fmt.Sprintf("This device does not yet have read access to "+
"directory %s, log into Keybase from one of your other "+
"devices to grant access: %+v",
tlfhandle.BuildCanonicalPathForTlfName(tlf.Private, e.Tlf), e.Err)
}
// ToStatus exports error to status
func (e NeedSelfRekeyError) ToStatus() keybase1.Status {
kv := keybase1.StringKVPair{
Key: "Tlf",
Value: string(e.Tlf),
}
return keybase1.Status{
Code: int(keybase1.StatusCode_SCNeedSelfRekey),
Name: "SC_NEED_SELF_REKEY",
Desc: e.Error(),
Fields: []keybase1.StringKVPair{kv},
}
}
// NeedOtherRekeyError indicates that the folder in question needs to
// be rekeyed for the local device, and can only done so by one of the
// other users.
type NeedOtherRekeyError struct {
Tlf tlf.CanonicalName
Err error
}
// Error implements the error interface for NeedOtherRekeyError
func (e NeedOtherRekeyError) Error() string {
return fmt.Sprintf("This device does not yet have read access to "+
"directory %s, ask one of the other directory participants to "+
"log into Keybase to grant you access automatically: %+v",
tlfhandle.BuildCanonicalPathForTlfName(tlf.Private, e.Tlf), e.Err)
}
// ToStatus exports error to status
func (e NeedOtherRekeyError) ToStatus() keybase1.Status {
kv := keybase1.StringKVPair{
Key: "Tlf",
Value: string(e.Tlf),
}
return keybase1.Status{
Code: int(keybase1.StatusCode_SCNeedOtherRekey),
Name: "SC_NEED_OTHER_REKEY",
Desc: e.Error(),
Fields: []keybase1.StringKVPair{kv},
}
}
// NotFileBlockError indicates that a file block was expected but a
// block of a different type was found.
//
// ptr and branch should be filled in, but p may be empty.
type NotFileBlockError struct {
ptr data.BlockPointer
branch data.BranchName
p data.Path
}
func (e NotFileBlockError) Error() string {
return fmt.Sprintf("The block at %s is not a file block (branch=%s, path=%s)", e.ptr, e.branch, e.p)
}
// NotDirBlockError indicates that a file block was expected but a
// block of a different type was found.
//
// ptr and branch should be filled in, but p may be empty.
type NotDirBlockError struct {
ptr data.BlockPointer
branch data.BranchName
p data.Path
}
func (e NotDirBlockError) Error() string {
return fmt.Sprintf("The block at %s is not a dir block (branch=%s, path=%s)", e.ptr, e.branch, e.p)
}
// NotFileError indicates that the user tried to perform a
// file-specific operation on something that isn't a file.
type NotFileError struct {
path data.Path
}
// Error implements the error interface for NotFileError
func (e NotFileError) Error() string {
return fmt.Sprintf("%s is not a file (folder %s)", e.path, e.path.Tlf)
}
// NotDirError indicates that the user tried to perform a
// dir-specific operation on something that isn't a directory.
type NotDirError struct {
path data.Path
}
// Error implements the error interface for NotDirError
func (e NotDirError) Error() string {
return fmt.Sprintf("%s is not a directory (folder %s)", e.path, e.path.Tlf)
}
// BlockDecodeError indicates that a block couldn't be decoded as
// expected; probably it is the wrong type.
type BlockDecodeError struct {
decodeErr error
}
// Error implements the error interface for BlockDecodeError
func (e BlockDecodeError) Error() string {
return fmt.Sprintf("Decode error for a block: %v", e.decodeErr)
}
// BadCryptoError indicates that KBFS performed a bad crypto operation.
type BadCryptoError struct {
ID kbfsblock.ID
}
// Error implements the error interface for BadCryptoError
func (e BadCryptoError) Error() string {
return fmt.Sprintf("Bad crypto for block %v", e.ID)
}
// BadCryptoMDError indicates that KBFS performed a bad crypto
// operation, specifically on a MD object.
type BadCryptoMDError struct {
ID tlf.ID
}
// Error implements the error interface for BadCryptoMDError
func (e BadCryptoMDError) Error() string {
return fmt.Sprintf("Bad crypto for the metadata of directory %v", e.ID)
}
// BadMDError indicates that the system is storing corrupt MD object
// for the given TLF ID.
type BadMDError struct {
ID tlf.ID
}
// Error implements the error interface for BadMDError
func (e BadMDError) Error() string {
return fmt.Sprintf("Wrong format for metadata for directory %v", e.ID)
}
// MDMismatchError indicates an inconsistent or unverifiable MD object
// for the given top-level folder.
type MDMismatchError struct {
Revision kbfsmd.Revision
Dir string
TlfID tlf.ID
Err error
}
// Error implements the error interface for MDMismatchError
func (e MDMismatchError) Error() string {
return fmt.Sprintf("Could not verify metadata (revision=%d) for directory %s (id=%s): %s",
e.Revision, e.Dir, e.TlfID, e.Err)
}
// NoSuchMDError indicates that there is no MD object for the given
// folder, revision, and merged status.
type NoSuchMDError struct {
Tlf tlf.ID
Rev kbfsmd.Revision
BID kbfsmd.BranchID
}
// Error implements the error interface for NoSuchMDError
func (e NoSuchMDError) Error() string {
return fmt.Sprintf("Couldn't get metadata for folder %v, revision %d, "+
"%s", e.Tlf, e.Rev, e.BID)
}
// InvalidDataVersionError indicates that an invalid data version was
// used.
type InvalidDataVersionError struct {
DataVer data.Ver
}
// Error implements the error interface for InvalidDataVersionError.
func (e InvalidDataVersionError) Error() string {
return fmt.Sprintf("Invalid data version %d", int(e.DataVer))
}
// NewDataVersionError indicates that the data at the given path has
// been written using a new data version that our client doesn't
// understand.
type NewDataVersionError struct {
path data.Path
DataVer data.Ver
}
// Error implements the error interface for NewDataVersionError.
func (e NewDataVersionError) Error() string {
return fmt.Sprintf(
"The data at path %s is of a version (%d) that we can't read "+
"(in folder %s)",
e.path, e.DataVer, e.path.Tlf)
}
// OutdatedVersionError indicates that we have encountered some new
// data version we don't understand, and the user should be prompted
// to upgrade.
type OutdatedVersionError struct {
}
// Error implements the error interface for OutdatedVersionError.
func (e OutdatedVersionError) Error() string {
return "Your software is out of date, and cannot read this data. " +
"Please use `keybase update check` to upgrade your software."
}
// InvalidVersionError indicates that we have encountered some new data version
// we don't understand, and we don't know how to handle it.
type InvalidVersionError struct {
msg string
}
// Error implements the error interface for InvalidVersionError.
func (e InvalidVersionError) Error() string {
if e.msg != "" {
return e.msg
}
return "The version provided is not valid."
}
// TooLowByteCountError indicates that size of a block is smaller than
// the expected size.
type TooLowByteCountError struct {
ExpectedMinByteCount int
ByteCount int
}
// Error implements the error interface for TooLowByteCountError
func (e TooLowByteCountError) Error() string {
return fmt.Sprintf("Expected at least %d bytes, got %d bytes",
e.ExpectedMinByteCount, e.ByteCount)
}
// InconsistentEncodedSizeError is raised when a dirty block has a
// non-zero encoded size.
type InconsistentEncodedSizeError struct {
info data.BlockInfo
}
// Error implements the error interface for InconsistentEncodedSizeError
func (e InconsistentEncodedSizeError) Error() string {
return fmt.Sprintf("Block pointer to dirty block %v with non-zero "+
"encoded size = %d bytes", e.info.ID, e.info.EncodedSize)
}
// MDWriteNeededInRequest indicates that the system needs MD write
// permissions to successfully complete an operation, so it should
// retry in mdWrite mode.
type MDWriteNeededInRequest struct {
}
// Error implements the error interface for MDWriteNeededInRequest
func (e MDWriteNeededInRequest) Error() string {
return "This request needs MD write access, but doesn't have it."
}
// VerifyingKeyNotFoundError indicates that a verifying key matching
// the given one couldn't be found.
type VerifyingKeyNotFoundError struct {
key kbfscrypto.VerifyingKey
}
func (e VerifyingKeyNotFoundError) Error() string {
return fmt.Sprintf("Could not find verifying key %s", e.key)
}
// UnverifiableTlfUpdateError indicates that a MD update could not be
// verified.
type UnverifiableTlfUpdateError struct {
Tlf string
User kbname.NormalizedUsername
Err error
}
// Error implements the error interface for UnverifiableTlfUpdateError.
func (e UnverifiableTlfUpdateError) Error() string {
return fmt.Sprintf("%s was last written by an unknown device claiming "+
"to belong to user %s. The device has possibly been revoked by the "+
"user. Use `keybase log send` to file an issue with the Keybase "+
"admins.", e.Tlf, e.User)
}
// KeyCacheMissError indicates that a key matching the given TLF ID
// and key generation wasn't found in cache.
type KeyCacheMissError struct {
tlf tlf.ID
keyGen kbfsmd.KeyGen
}
// Error implements the error interface for KeyCacheMissError.
func (e KeyCacheMissError) Error() string {
return fmt.Sprintf("Could not find key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
}
// KeyCacheHitError indicates that a key matching the given TLF ID
// and key generation was found in cache but the object type was unknown.
type KeyCacheHitError struct {
tlf tlf.ID
keyGen kbfsmd.KeyGen
}
// Error implements the error interface for KeyCacheHitError.
func (e KeyCacheHitError) Error() string {
return fmt.Sprintf("Invalid key with tlf=%s, keyGen=%d", e.tlf, e.keyGen)
}
// NoKeysError indicates that no keys were provided for a decryption allowing
// multiple device keys
type NoKeysError struct{}
func (e NoKeysError) Error() string {
return "No keys provided"
}
// WrongOpsError indicates that an unexpected path got passed into a
// FolderBranchOps instance
type WrongOpsError struct {
nodeFB data.FolderBranch
opsFB data.FolderBranch
}
// Error implements the error interface for WrongOpsError.
func (e WrongOpsError) Error() string {
return fmt.Sprintf("Ops for folder %v, branch %s, was given path %s, "+
"branch %s", e.opsFB.Tlf, e.opsFB.Branch, e.nodeFB.Tlf, e.nodeFB.Branch)
}
// NodeNotFoundError indicates that we tried to find a node for the
// given BlockPointer and failed.
type NodeNotFoundError struct {
ptr data.BlockPointer
}
// Error implements the error interface for NodeNotFoundError.
func (e NodeNotFoundError) Error() string {
return fmt.Sprintf("No node found for pointer %v", e.ptr)
}
// ParentNodeNotFoundError indicates that we tried to update a Node's
// parent with a BlockPointer that we don't yet know about.
type ParentNodeNotFoundError struct {
parent data.BlockRef
}
// Error implements the error interface for ParentNodeNotFoundError.
func (e ParentNodeNotFoundError) Error() string {
return fmt.Sprintf("No such parent node found for %v", e.parent)
}
// EmptyNameError indicates that the user tried to use an empty name
// for the given BlockRef.
type EmptyNameError struct {
ref data.BlockRef
}
// Error implements the error interface for EmptyNameError.
func (e EmptyNameError) Error() string {
return fmt.Sprintf("Cannot use empty name for %v", e.ref)
}
// KeyHalfMismatchError is returned when the key server doesn't return the expected key half.
type KeyHalfMismatchError struct {
Expected kbfscrypto.TLFCryptKeyServerHalfID
Actual kbfscrypto.TLFCryptKeyServerHalfID
}
// Error implements the error interface for KeyHalfMismatchError.
func (e KeyHalfMismatchError) Error() string {
return fmt.Sprintf("Key mismatch, expected ID: %s, actual ID: %s",
e.Expected, e.Actual)
}
// MDServerDisconnected indicates the MDServer has been disconnected for clients waiting
// on an update channel.
type MDServerDisconnected struct {
}
// Error implements the error interface for MDServerDisconnected.
func (e MDServerDisconnected) Error() string {
return "MDServer is disconnected"
}
// MDUpdateInvertError indicates that we tried to apply a revision that
// was not the next in line.
type MDUpdateInvertError struct {
rev kbfsmd.Revision
curr kbfsmd.Revision
}
// Error implements the error interface for MDUpdateInvertError.
func (e MDUpdateInvertError) Error() string {
return fmt.Sprintf("MD revision %d isn't next in line for our "+
"current revision %d while inverting", e.rev, e.curr)
}
// NotPermittedWhileDirtyError indicates that some operation failed
// because of outstanding dirty files, and may be retried later.
type NotPermittedWhileDirtyError struct {
}
// Error implements the error interface for NotPermittedWhileDirtyError.
func (e NotPermittedWhileDirtyError) Error() string {
return "Not permitted while writes are dirty"
}
// NoChainFoundError indicates that a conflict resolution chain
// corresponding to the given pointer could not be found.
type NoChainFoundError struct {
ptr data.BlockPointer
}
// Error implements the error interface for NoChainFoundError.
func (e NoChainFoundError) Error() string {
return fmt.Sprintf("No chain found for %v", e.ptr)
}
// DisallowedPrefixError indicates that the user attempted to create
// an entry using a name with a disallowed prefix.
type DisallowedPrefixError struct {
name data.PathPartString
prefix string
}
// Error implements the error interface for NoChainFoundError.
func (e DisallowedPrefixError) Error() string {
return fmt.Sprintf("Cannot create %s because it has the prefix %s",
e.name, e.prefix)
}
// NameTooLongError indicates that the user tried to write a directory
// entry name that would be bigger than KBFS's supported size.
type NameTooLongError struct {
name string
maxAllowedBytes uint32
}
// Error implements the error interface for NameTooLongError.
func (e NameTooLongError) Error() string {
return fmt.Sprintf("New directory entry name %s has more than the maximum "+
"allowed number of bytes (%d)", e.name, e.maxAllowedBytes)
}
// NoCurrentSessionExpectedError is the error text that will get
// converted into a NoCurrentSessionError.
var NoCurrentSessionExpectedError = "no current session"
// RekeyPermissionError indicates that the user tried to rekey a
// top-level folder in a manner inconsistent with their permissions.
type RekeyPermissionError struct {
User kbname.NormalizedUsername
Dir string
}
// Error implements the error interface for RekeyPermissionError
func (e RekeyPermissionError) Error() string {
return fmt.Sprintf("%s is trying to rekey directory %s in a manner "+
"inconsistent with their role", e.User, e.Dir)
}
// NewRekeyPermissionError constructs a RekeyPermissionError for the given
// directory and user.
func NewRekeyPermissionError(
dir *tlfhandle.Handle, username kbname.NormalizedUsername) error {
dirname := dir.GetCanonicalPath()
return RekeyPermissionError{username, dirname}
}
// RekeyIncompleteError is returned when a rekey is partially done but
// needs a writer to finish it.
type RekeyIncompleteError struct{}
func (e RekeyIncompleteError) Error() string {
return fmt.Sprintf("Rekey did not complete due to insufficient user permissions")
}
// TimeoutError is just a replacement for context.DeadlineExceeded
// with a more friendly error string.
type TimeoutError struct {
}
func (e TimeoutError) Error() string {
return "Operation timed out"
}
// InvalidOpError is returned when an operation is called that isn't supported
// by the current implementation.
type InvalidOpError struct {
op string
}
func (e InvalidOpError) Error() string {
return fmt.Sprintf("Invalid operation: %s", e.op)
}
// NoSuchFolderListError indicates that the user tried to access a
// subdirectory of /keybase that doesn't exist.
type NoSuchFolderListError struct {
Name string
NameToLog string
PrivName string
PubName string
}
// Error implements the error interface for NoSuchFolderListError
func (e NoSuchFolderListError) Error() string {
return fmt.Sprintf("/keybase/%s is not a Keybase folder. "+
"All folders begin with /keybase/%s or /keybase/%s.",
e.NameToLog, e.PrivName, e.PubName)
}
// UnexpectedUnmergedPutError indicates that we tried to do an
// unmerged put when that was disallowed.
type UnexpectedUnmergedPutError struct {
}
// Error implements the error interface for UnexpectedUnmergedPutError
func (e UnexpectedUnmergedPutError) Error() string {
return "Unmerged puts are not allowed"
}
// NoSuchTlfHandleError indicates we were unable to resolve a folder
// ID to a folder handle.
type NoSuchTlfHandleError struct {
ID tlf.ID
}
// Error implements the error interface for NoSuchTlfHandleError
func (e NoSuchTlfHandleError) Error() string {
return fmt.Sprintf("Folder handle for %s not found", e.ID)
}
// NoSuchTlfIDError indicates we were unable to resolve a folder
// handle to a folder ID.
type NoSuchTlfIDError struct {
handle *tlfhandle.Handle
}
// Error implements the error interface for NoSuchTlfIDError
func (e NoSuchTlfIDError) Error() string {
return fmt.Sprintf("Folder ID for %s not found",
e.handle.GetCanonicalPath())
}
// IncompatibleHandleError indicates that somethine tried to update
// the head of a TLF with a RootMetadata with an incompatible handle.
type IncompatibleHandleError struct {
oldName tlf.CanonicalName
partiallyResolvedOldName tlf.CanonicalName
newName tlf.CanonicalName
}
func (e IncompatibleHandleError) Error() string {
return fmt.Sprintf(
"old head %q resolves to %q instead of new head %q",
e.oldName, e.partiallyResolvedOldName, e.newName)
}
// UnmergedError indicates that fbo is on an unmerged local revision
type UnmergedError struct {
}
// Error implements the error interface for UnmergedError.
func (e UnmergedError) Error() string {
return "fbo is on an unmerged local revision"
}
// ExclOnUnmergedError happens when an operation with O_EXCL set when fbo is on
// an unmerged local revision
type ExclOnUnmergedError struct {
}
// Error implements the error interface for ExclOnUnmergedError.
func (e ExclOnUnmergedError) Error() string {
return "an operation with O_EXCL set is called but fbo is on an unmerged local version"
}
// OverQuotaWarning indicates that the user is over their quota, and
// is being slowed down by the server.
type OverQuotaWarning struct {
UsageBytes int64
LimitBytes int64
}
// Error implements the error interface for OverQuotaWarning.
func (w OverQuotaWarning) Error() string {
return fmt.Sprintf("You are using %d bytes, and your plan limits you "+
"to %d bytes. Please delete some data.", w.UsageBytes, w.LimitBytes)
}
// OpsCantHandleFavorite means that folderBranchOps wasn't able to
// deal with a favorites request.
type OpsCantHandleFavorite struct {
Msg string
}
// Error implements the error interface for OpsCantHandleFavorite.
func (e OpsCantHandleFavorite) Error() string {
return fmt.Sprintf("Couldn't handle the favorite operation: %s", e.Msg)
}
// RekeyConflictError indicates a conflict happened while trying to rekey.
type RekeyConflictError struct {
Err error
}
// Error implements the error interface for RekeyConflictError.
func (e RekeyConflictError) Error() string {
return fmt.Sprintf("Conflict during a rekey, not retrying: %v", e.Err)
}
// UnmergedSelfConflictError indicates that we hit a conflict on the
// unmerged branch, so a previous MD PutUnmerged we thought had
// failed, had actually succeeded.
type UnmergedSelfConflictError struct {
Err error
}
// Error implements the error interface for UnmergedSelfConflictError.
func (e UnmergedSelfConflictError) Error() string {
return fmt.Sprintf("Unmerged self conflict: %v", e.Err)
}
// blockNonExistentError is returned when a block doesn't exist. This
// is a generic error, suitable for use by non-server types, whereas
// kbfsblock.ServerErrorBlockNonExistent is used only by servers.
type blockNonExistentError struct {
id kbfsblock.ID
}
func (e blockNonExistentError) Error() string {
return fmt.Sprintf("block %s does not exist", e.id)
}
// NoMergedMDError indicates that no MDs for this folder have been
// created yet.
type NoMergedMDError struct {
tlf tlf.ID
}
// Error implements the error interface for NoMergedMDError.
func (e NoMergedMDError) Error() string {
return fmt.Sprintf("No MD yet for TLF %s", e.tlf)
}
// InvalidFavoritesOpError indicates an unknown FavoritesOp has been provided.
type InvalidFavoritesOpError struct{}
// Error implements the error interface for InvalidFavoritesOpError.
func (InvalidFavoritesOpError) Error() string {
return "invalid FavoritesOp"
}
// DiskCacheClosedError indicates that the disk cache has been
// closed, and thus isn't accepting any more operations.
type DiskCacheClosedError struct {
op string
}
// Error implements the error interface for DiskCacheClosedError.
func (e DiskCacheClosedError) Error() string {
return fmt.Sprintf("Error performing %s operation: the disk cache is "+
"closed", e.op)
}
// DiskCacheStartingError indicates that the disk cache has not yet started, so
// it isn't yet accepting operations.
type DiskCacheStartingError struct {
op string
}
// Error implements the error interface for DiskCacheStartingError.
func (e DiskCacheStartingError) Error() string {
return fmt.Sprintf("Error performing %s operation: the disk cache is "+
"still starting", e.op)
}
// NoUpdatesWhileDirtyError indicates that updates aren't being
// accepted while a TLF is locally dirty.
type NoUpdatesWhileDirtyError struct{}
// Error implements the error interface for NoUpdatesWhileDirtyError.
func (e NoUpdatesWhileDirtyError) Error() string {
return "Ignoring MD updates while writes are dirty"
}
// Disk Cache Errors
const (
// StatusCodeDiskBlockCacheError is a generic disk cache error.
StatusCodeDiskBlockCacheError = 0x666
// StatusCodeDiskMDCacheError is a generic disk cache error.
StatusCodeDiskMDCacheError = 0x667
// StatusCodeDiskQuotaCacheError is a generic disk cache error.
StatusCodeDiskQuotaCacheError = 0x668
)
// DiskBlockCacheError is a generic disk cache error.
type DiskBlockCacheError struct {
Msg string
}
func newDiskBlockCacheError(err error) DiskBlockCacheError {
return DiskBlockCacheError{err.Error()}
}
// ToStatus implements the ExportableError interface for DiskBlockCacheError.
func (e DiskBlockCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskBlockCacheError
s.Name = "DISK_BLOCK_CACHE_ERROR"
s.Desc = e.Msg
return
}
// Error implements the Error interface for DiskBlockCacheError.
func (e DiskBlockCacheError) Error() string {
return "DiskBlockCacheError{" + e.Msg + "}"
}
// DiskMDCacheError is a generic disk cache error.
type DiskMDCacheError struct {
Msg string
}
func newDiskMDCacheError(err error) DiskMDCacheError {
return DiskMDCacheError{err.Error()}
}
// ToStatus implements the ExportableError interface for DiskMDCacheError.
func (e DiskMDCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskMDCacheError
s.Name = "DISK_MD_CACHE_ERROR"
s.Desc = e.Msg
return
}
// Error implements the Error interface for DiskMDCacheError.
func (e DiskMDCacheError) Error() string {
return "DiskMDCacheError{" + e.Msg + "}"
}
// DiskQuotaCacheError is a generic disk cache error.
type DiskQuotaCacheError struct {
Msg string
}
func newDiskQuotaCacheError(err error) DiskQuotaCacheError {
return DiskQuotaCacheError{err.Error()}
}
// ToStatus implements the ExportableError interface for DiskQuotaCacheError.
func (e DiskQuotaCacheError) ToStatus() (s keybase1.Status) {
s.Code = StatusCodeDiskQuotaCacheError
s.Name = "DISK_QUOTA_CACHE_ERROR"
s.Desc = e.Msg
return
}
// Error implements the Error interface for DiskQuotaCacheError.
func (e DiskQuotaCacheError) Error() string {
return "DiskQuotaCacheError{" + e.Msg + "}"
}
// RevokedDeviceVerificationError indicates that the user is trying to
// verify a key that has been revoked. It includes useful information
// about the revocation, so the code receiving the error can check if
// the device was valid at the time of the data being checked.
type RevokedDeviceVerificationError struct {
info idutil.RevokedKeyInfo
}
// Error implements the Error interface for RevokedDeviceVerificationError.
func (e RevokedDeviceVerificationError) Error() string {
return fmt.Sprintf("Device was revoked at time %s, root seqno %d",
e.info.Time.Time().Format(time.RFC3339Nano), e.info.MerkleRoot.Seqno)
}
// MDWrittenAfterRevokeError indicates that we failed to verify an MD
// revision because it was written after the last valid revision that
// the corresponding device could have written.
type MDWrittenAfterRevokeError struct {
tlfID tlf.ID
revBad kbfsmd.Revision
revLimit kbfsmd.Revision
verifyingKey kbfscrypto.VerifyingKey
}
// Error implements the Error interface for MDWrittenAfterRevokeError.
func (e MDWrittenAfterRevokeError) Error() string {
return fmt.Sprintf("Failed to verify revision %d of folder %s by key %s; "+
"last valid revision would have been %d",
e.revBad, e.tlfID, e.verifyingKey, e.revLimit)
}
// RevGarbageCollectedError indicates that the user is trying to
// access a revision that's already been garbage-collected.
type RevGarbageCollectedError struct {
rev kbfsmd.Revision
lastGCRev kbfsmd.Revision
}
// Error implements the Error interface for RevGarbageCollectedError.
func (e RevGarbageCollectedError) Error() string {
return fmt.Sprintf("Requested revision %d has already been garbage "+
"collected (last GC'd rev=%d)", e.rev, e.lastGCRev)
}
// FolderNotResetOnServer indicates that a folder can't be reset by
// the user, because it hasn't yet been reset on the mdserver.
type FolderNotResetOnServer struct {
h *tlfhandle.Handle
}
// Error implements the Error interface for FolderNotResetOnServer.
func (e FolderNotResetOnServer) Error() string {
return fmt.Sprintf("Folder %s is not yet reset on the server; "+
"contact Keybase for help", e.h.GetCanonicalPath())
}
// OfflineArchivedError indicates trying to access archived data while
// offline.
type OfflineArchivedError struct {
h *tlfhandle.Handle
}
// Error implements the Error interface for OfflineArchivedError.
func (e OfflineArchivedError) Error() string {
return fmt.Sprintf("Archived data from %s is not available while offline",
e.h.GetCanonicalPath())
}
// OfflineUnsyncedError indicates trying to access unsynced data while
// offline.
type OfflineUnsyncedError struct {
h *tlfhandle.Handle