github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/kbfsmd/errors.go (about) 1 // Copyright 2017 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package kbfsmd 6 7 import ( 8 "fmt" 9 10 "github.com/keybase/client/go/kbfs/tlf" 11 ) 12 13 // MissingDataError indicates that we are trying to take get the 14 // metadata ID of a MD object with no serialized data field. 15 type MissingDataError struct { 16 tlfID tlf.ID 17 } 18 19 // Error implements the error interface for MissingDataError 20 func (e MissingDataError) Error() string { 21 return fmt.Sprintf("No serialized private data in the metadata "+ 22 "for directory %v", e.tlfID) 23 } 24 25 // InvalidBranchID indicates whether the branch ID string is not 26 // parseable or invalid. 27 type InvalidBranchID struct { 28 id string 29 } 30 31 func (e InvalidBranchID) Error() string { 32 return fmt.Sprintf("Invalid branch ID %q", e.id) 33 } 34 35 // MetadataIsFinalError indicates that we tried to make or set a 36 // successor to a finalized folder. 37 type MetadataIsFinalError struct { 38 } 39 40 // Error implements the error interface for MetadataIsFinalError. 41 func (e MetadataIsFinalError) Error() string { 42 return "Metadata is final" 43 } 44 45 // MDTlfIDMismatch indicates that the ID field of a successor MD 46 // doesn't match the ID field of its predecessor. 47 type MDTlfIDMismatch struct { 48 CurrID tlf.ID 49 NextID tlf.ID 50 } 51 52 func (e MDTlfIDMismatch) Error() string { 53 return fmt.Sprintf("TLF ID %s doesn't match successor TLF ID %s", 54 e.CurrID, e.NextID) 55 } 56 57 // MDRevisionMismatch indicates that we tried to apply a revision that 58 // was not the next in line. 59 type MDRevisionMismatch struct { 60 Rev Revision 61 Curr Revision 62 } 63 64 // Error implements the error interface for MDRevisionMismatch. 65 func (e MDRevisionMismatch) Error() string { 66 return fmt.Sprintf("MD revision %d isn't next in line for our "+ 67 "current revision %d", e.Rev, e.Curr) 68 } 69 70 // MDPrevRootMismatch indicates that the PrevRoot field of a successor 71 // MD doesn't match the metadata ID of its predecessor. 72 type MDPrevRootMismatch struct { 73 prevRoot ID 74 expectedPrevRoot ID 75 } 76 77 func (e MDPrevRootMismatch) Error() string { 78 return fmt.Sprintf("PrevRoot %s doesn't match expected %s", 79 e.prevRoot, e.expectedPrevRoot) 80 } 81 82 // MDDiskUsageMismatch indicates an inconsistency in the DiskUsage 83 // field of a RootMetadata object. 84 type MDDiskUsageMismatch struct { 85 expectedDiskUsage uint64 86 actualDiskUsage uint64 87 } 88 89 func (e MDDiskUsageMismatch) Error() string { 90 return fmt.Sprintf("Disk usage %d doesn't match expected %d", 91 e.actualDiskUsage, e.expectedDiskUsage) 92 } 93 94 // InvalidNonPrivateTLFOperation indicates that an invalid operation was 95 // attempted on a public or team TLF. 96 type InvalidNonPrivateTLFOperation struct { 97 id tlf.ID 98 opName string 99 ver MetadataVer 100 } 101 102 // Error implements the error interface for InvalidNonPrivateTLFOperation. 103 func (e InvalidNonPrivateTLFOperation) Error() string { 104 return fmt.Sprintf( 105 "Tried to do invalid operation %s on non-private TLF %v (ver=%v)", 106 e.opName, e.id, e.ver) 107 } 108 109 // InvalidKeyGenerationError indicates that an invalid key generation 110 // was used. 111 type InvalidKeyGenerationError struct { 112 TlfID tlf.ID 113 KeyGen KeyGen 114 } 115 116 // Error implements the error interface for InvalidKeyGenerationError. 117 func (e InvalidKeyGenerationError) Error() string { 118 return fmt.Sprintf("Invalid key generation %d for %s", int(e.KeyGen), e.TlfID) 119 } 120 121 // NewKeyGenerationError indicates that the data at the given path has 122 // been written using keys that our client doesn't have. 123 type NewKeyGenerationError struct { 124 TlfID tlf.ID 125 KeyGen KeyGen 126 } 127 128 // Error implements the error interface for NewKeyGenerationError. 129 func (e NewKeyGenerationError) Error() string { 130 return fmt.Sprintf( 131 "The data for %v is keyed with a key generation (%d) that "+ 132 "we don't know", e.TlfID, e.KeyGen) 133 } 134 135 // TLFCryptKeyNotPerDeviceEncrypted is returned when a given TLFCryptKey is not 136 // encrypted per-device but rather symmetrically encrypted with the current 137 // generation of the TLFCryptKey. 138 type TLFCryptKeyNotPerDeviceEncrypted struct { 139 tlf tlf.ID 140 keyGen KeyGen 141 } 142 143 // // Error implements the error interface for TLFCryptKeyNotPerDeviceEncrypted 144 func (e TLFCryptKeyNotPerDeviceEncrypted) Error() string { 145 return fmt.Sprintf("TLF crypt key for %s at generation %d is not per-device encrypted", 146 e.tlf, e.keyGen) 147 } 148 149 // InvalidMetadataVersionError indicates that an invalid metadata version was 150 // used. 151 type InvalidMetadataVersionError struct { 152 TlfID tlf.ID 153 MetadataVer MetadataVer 154 } 155 156 // Error implements the error interface for InvalidMetadataVersionError. 157 func (e InvalidMetadataVersionError) Error() string { 158 return fmt.Sprintf("Invalid metadata version %d for folder %s", 159 int(e.MetadataVer), e.TlfID) 160 } 161 162 // NewMetadataVersionError indicates that the metadata for the given 163 // folder has been written using a new metadata version that our 164 // client doesn't understand. 165 type NewMetadataVersionError struct { 166 Tlf tlf.ID 167 MetadataVer MetadataVer 168 } 169 170 // Error implements the error interface for NewMetadataVersionError. 171 func (e NewMetadataVersionError) Error() string { 172 return fmt.Sprintf( 173 "The metadata for folder %s is of a version (%d) that we can't read", 174 e.Tlf, e.MetadataVer) 175 } 176 177 // MutableRootMetadataNoImplError is returned when an interface expected 178 // to implement MutableRootMetadata does not do so. 179 type MutableRootMetadataNoImplError struct { 180 } 181 182 // Error implements the error interface for MutableRootMetadataNoImplError 183 func (e MutableRootMetadataNoImplError) Error() string { 184 return "Does not implement MutableRootMetadata" 185 } 186 187 // InvalidIDError indicates that a metadata ID string is not parseable 188 // or invalid. 189 type InvalidIDError struct { 190 id string 191 } 192 193 func (e InvalidIDError) Error() string { 194 return fmt.Sprintf("Invalid metadata ID %q", e.id) 195 } 196 197 // NewMerkleVersionError indicates that the merkle tree on the server 198 // is using a new metadata version that our client doesn't understand. 199 type NewMerkleVersionError struct { 200 Version int 201 } 202 203 // Error implements the error interface for NewMerkleVersionError. 204 func (e NewMerkleVersionError) Error() string { 205 return fmt.Sprintf( 206 "The merkle tree is of a version (%d) that we can't read", e.Version) 207 }