buffers.TooShort

master
Charles Iliya Krempeaux 2019-09-05 18:31:59 -07:00
parent 95e0d19807
commit df322d81e8
1 changed files with 32 additions and 0 deletions

32
tooshort.go 100644
View File

@ -0,0 +1,32 @@
package buffers
import (
"fmt"
)
type TooShort interface {
error
TooShort() (expectedAtLeast uint64, actual uint64)
}
func errTooShort(expectedAtLeast uint64, actual uint64) error {
var e TooShort = &internalTooShort{
expectedAtLeast:expectedAtLeast,
actual:actual,
}
return e
}
type internalTooShort struct {
expectedAtLeast uint64
actual uint64
}
func (receiver internalTooShort) Error() string {
return fmt.Sprintf("buffers: Backing Buffer Is Too Short: expected-at-least=%d actual=%d", receiver.expectedAtLeast, receiver.actual)
}
func (receiver internalTooShort) TooShort() (expectedAtLeast uint64, actual uint64) {
return receiver.expectedAtLeast, receiver.actual
}