github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/data/errors.go (about) 1 // Copyright 2019 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 data 6 7 import ( 8 "fmt" 9 10 "github.com/keybase/client/go/kbfs/kbfsblock" 11 ) 12 13 // NameExistsError indicates that the user tried to create an entry 14 // for a name that already existed in a subdirectory. 15 type NameExistsError struct { 16 Name string 17 } 18 19 // Error implements the error interface for NameExistsError 20 func (e NameExistsError) Error() string { 21 return fmt.Sprintf("%s already exists", e.Name) 22 } 23 24 // BadSplitError indicates that the BlockSplitter has an error. 25 type BadSplitError struct { 26 } 27 28 // Error implements the error interface for BadSplitError 29 func (e BadSplitError) Error() string { 30 return "Unexpected bad block split" 31 } 32 33 // BadDataError indicates that KBFS is storing corrupt data for a block. 34 type BadDataError struct { 35 ID kbfsblock.ID 36 } 37 38 // Error implements the error interface for BadDataError 39 func (e BadDataError) Error() string { 40 return fmt.Sprintf("Bad data for block %v", e.ID) 41 } 42 43 // NoSuchBlockError indicates that a block for the associated ID doesn't exist. 44 type NoSuchBlockError struct { 45 ID kbfsblock.ID 46 } 47 48 // Error implements the error interface for NoSuchBlockError 49 func (e NoSuchBlockError) Error() string { 50 return fmt.Sprintf("Couldn't get block %v", e.ID) 51 } 52 53 // NotDirectFileBlockError indicates that a direct file block was 54 // expected, but something else (e.g., an indirect file block) was 55 // given instead. 56 type NotDirectFileBlockError struct { 57 } 58 59 func (e NotDirectFileBlockError) Error() string { 60 return "Unexpected block type; expected a direct file block" 61 } 62 63 // CachePutCacheFullError indicates that a cache put failed because 64 // the cache was full. 65 type CachePutCacheFullError struct { 66 BlockID kbfsblock.ID 67 } 68 69 func (e CachePutCacheFullError) Error() string { 70 return fmt.Sprintf("failed to put block due to full cache. Block: %s", 71 e.BlockID) 72 } 73 74 // ShutdownHappenedError indicates that shutdown has happened. 75 type ShutdownHappenedError struct { 76 } 77 78 // Error implements the error interface for ShutdownHappenedError. 79 func (e ShutdownHappenedError) Error() string { 80 return "Shutdown happened" 81 }