forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
1161 lines (966 loc) · 34.6 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"
"github.com/keybase/client/go/libkb"
"github.com/keybase/client/go/protocol/keybase1"
"github.com/keybase/kbfs/kbfsblock"
"github.com/keybase/kbfs/kbfscrypto"
"github.com/keybase/kbfs/kbfsmd"
"github.com/keybase/kbfs/tlf"
)
// 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()
}
// NameExistsError indicates that the user tried to create an entry
// for a name that already existed in a subdirectory.
type NameExistsError struct {
Name string
}
// Error implements the error interface for NameExistsError
func (e NameExistsError) Error() string {
return fmt.Sprintf("%s already exists", e.Name)
}
// NoSuchNameError indicates that the user tried to access a
// subdirectory entry that doesn't exist.
type NoSuchNameError struct {
Name string
}
// Error implements the error interface for NoSuchNameError
func (e NoSuchNameError) Error() string {
return fmt.Sprintf("%s doesn't exist", e.Name)
}
// NoSuchUserError indicates that the given user couldn't be resolved.
type NoSuchUserError struct {
Input string
}
// Error implements the error interface for NoSuchUserError
func (e NoSuchUserError) Error() string {
return fmt.Sprintf("%s is not a Keybase user", e.Input)
}
// ToStatus implements the keybase1.ToStatusAble interface for NoSuchUserError
func (e NoSuchUserError) ToStatus() keybase1.Status {
return keybase1.Status{
Name: "NotFound",
Code: int(keybase1.StatusCode_SCNotFound),
Desc: e.Error(),
}
}
// NoSuchTeamError indicates that the given team couldn't be resolved.
type NoSuchTeamError struct {
Input string
}
// Error implements the error interface for NoSuchTeamError
func (e NoSuchTeamError) Error() string {
return fmt.Sprintf("%s is not a Keybase team", e.Input)
}
// BadTLFNameError indicates a top-level folder name that has an
// incorrect format.
type BadTLFNameError struct {
Name string
}
// Error implements the error interface for BadTLFNameError.
func (e BadTLFNameError) Error() string {
return fmt.Sprintf("TLF name %s is in an incorrect format", e.Name)
}
// InvalidBlockRefError indicates an invalid block reference was
// encountered.
type InvalidBlockRefError struct {
ref 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 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 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 string
}
// 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)
}
// ReadAccessError indicates that the user tried to read from a
// top-level folder without read permission.
type ReadAccessError struct {
User libkb.NormalizedUsername
Filename string
Tlf tlf.CanonicalName
Type tlf.Type
}
// Error implements the error interface for ReadAccessError
func (e ReadAccessError) Error() string {
return fmt.Sprintf("%s does not have read access to directory %s",
e.User, buildCanonicalPathForTlfName(e.Type, e.Tlf))
}
// WriteAccessError indicates an error when trying to write a file
type WriteAccessError struct {
User libkb.NormalizedUsername
Filename string
Tlf tlf.CanonicalName
Type tlf.Type
}
// Error implements the error interface for WriteAccessError
func (e WriteAccessError) Error() string {
if e.Tlf != "" {
return fmt.Sprintf("%s does not have write access to directory %s",
e.User, buildCanonicalPathForTlfName(e.Type, e.Tlf))
}
return fmt.Sprintf("%s does not have write access to %s", e.User, e.Filename)
}
// 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)
}
// NewReadAccessError constructs a ReadAccessError for the given
// directory and user.
func NewReadAccessError(h *TlfHandle, username libkb.NormalizedUsername, filename string) error {
tlfname := h.GetCanonicalName()
return ReadAccessError{
User: username,
Filename: filename,
Tlf: tlfname,
Type: h.Type(),
}
}
// NewWriteAccessError is an access error trying to write a file
func NewWriteAccessError(h *TlfHandle, username libkb.NormalizedUsername, filename string) error {
tlfName := tlf.CanonicalName("")
t := tlf.Private
if h != nil {
tlfName = h.GetCanonicalName()
t = h.Type()
}
return WriteAccessError{
User: username,
Filename: filename,
Tlf: tlfName,
Type: t,
}
}
// 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", 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",
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 BlockPointer
branch BranchName
p 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 BlockPointer
branch BranchName
p 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 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 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)
}
// BadDataError indicates that KBFS is storing corrupt data for a block.
type BadDataError struct {
ID kbfsblock.ID
}
// Error implements the error interface for BadDataError
func (e BadDataError) Error() string {
return fmt.Sprintf("Bad data for block %v", e.ID)
}
// NoSuchBlockError indicates that a block for the associated ID doesn't exist.
type NoSuchBlockError struct {
ID kbfsblock.ID
}
// Error implements the error interface for NoSuchBlockError
func (e NoSuchBlockError) Error() string {
return fmt.Sprintf("Couldn't get block %v", e.ID)
}
// 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 DataVer
}
// 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 path
DataVer DataVer
}
// 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."
}
// BadSplitError indicates that the BlockSplitter has an error.
type BadSplitError struct {
}
// Error implements the error interface for BadSplitError
func (e BadSplitError) Error() string {
return "Unexpected bad block split"
}
// 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 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 libkb.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 FolderBranch
opsFB 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 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 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 BlockRef
}
// Error implements the error interface for EmptyNameError.
func (e EmptyNameError) Error() string {
return fmt.Sprintf("Cannot use empty name for %v", e.ref)
}
// PaddedBlockReadError occurs if the number of bytes read do not
// equal the number of bytes specified.
type PaddedBlockReadError struct {
ActualLen int
ExpectedLen int
}
// Error implements the error interface of PaddedBlockReadError.
func (e PaddedBlockReadError) Error() string {
return fmt.Sprintf("Reading block data out of padded block resulted in %d bytes, expected %d",
e.ActualLen, e.ExpectedLen)
}
// NotDirectFileBlockError indicates that a direct file block was
// expected, but something else (e.g., an indirect file block) was
// given instead.
type NotDirectFileBlockError struct {
}
func (e NotDirectFileBlockError) Error() string {
return fmt.Sprintf("Unexpected block type; expected a direct file block")
}
// 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 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 string
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)
}
// FileTooBigError indicates that the user tried to write a file that
// would be bigger than KBFS's supported size.
type FileTooBigError struct {
p path
size int64
maxAllowedBytes uint64
}
// Error implements the error interface for FileTooBigError.
func (e FileTooBigError) Error() string {
return fmt.Sprintf("File %s would have increased to %d bytes, which is "+
"over the supported limit of %d bytes", e.p, e.size, e.maxAllowedBytes)
}
// 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)
}
// DirTooBigError indicates that the user tried to write a directory
// that would be bigger than KBFS's supported size.
type DirTooBigError struct {
p path
size uint64
maxAllowedBytes uint64
}
// Error implements the error interface for DirTooBigError.
func (e DirTooBigError) Error() string {
return fmt.Sprintf("Directory %s would have increased to at least %d "+
"bytes, which is over the supported limit of %d bytes", e.p,
e.size, e.maxAllowedBytes)
}
// TlfNameNotCanonical indicates that a name isn't a canonical, and
// that another (not necessarily canonical) name should be tried.
type TlfNameNotCanonical struct {
Name, NameToTry string
}
func (e TlfNameNotCanonical) Error() string {
return fmt.Sprintf("TLF name %s isn't canonical: try %s instead",
e.Name, e.NameToTry)
}
// NoCurrentSessionError indicates that the daemon has no current
// session. This is basically a wrapper for session.ErrNoSession,
// needed to give the correct return error code to the OS.
type NoCurrentSessionError struct {
}
// Error implements the error interface for NoCurrentSessionError.
func (e NoCurrentSessionError) Error() string {
return "You are not logged into Keybase. Try `keybase login`."
}
// 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 libkb.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, username libkb.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)
}
// CRAbandonStagedBranchError indicates that conflict resolution had to
// abandon a staged branch due to an unresolvable error.
type CRAbandonStagedBranchError struct {
Err error
Bid kbfsmd.BranchID
}
func (e CRAbandonStagedBranchError) Error() string {
return fmt.Sprintf("Abandoning staged branch %s due to an error: %v",
e.Bid, e.Err)
}
// NoSuchFolderListError indicates that the user tried to access a
// subdirectory of /keybase that doesn't exist.
type NoSuchFolderListError struct {
Name 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.Name, 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
}
// 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)
}
// ShutdownHappenedError indicates that shutdown has happened.
type ShutdownHappenedError struct {
}
// Error implements the error interface for ShutdownHappenedError.
func (e ShutdownHappenedError) Error() string {
return "Shutdown happened"
}
// 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