github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/kbfshash/errors.go (about) 1 // Copyright 2016 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 kbfshash 6 7 import "fmt" 8 9 // InvalidHashError is returned whenever an invalid hash is 10 // detected. 11 type InvalidHashError struct { 12 H Hash 13 } 14 15 func (e InvalidHashError) Error() string { 16 return fmt.Sprintf("Invalid hash %s", e.H) 17 } 18 19 // UnknownHashTypeError is returned whenever a hash with an unknown 20 // hash type is attempted to be used for verification. 21 type UnknownHashTypeError struct { 22 T HashType 23 } 24 25 func (e UnknownHashTypeError) Error() string { 26 return fmt.Sprintf("Unknown hash type %s", e.T) 27 } 28 29 // HashMismatchError is returned whenever a hash mismatch is detected. 30 type HashMismatchError struct { 31 ExpectedH Hash 32 ActualH Hash 33 } 34 35 func (e HashMismatchError) Error() string { 36 return fmt.Sprintf("Hash mismatch: expected %s, got %s", 37 e.ExpectedH, e.ActualH) 38 }