github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/decimal/errors.go (about) 1 package decimal 2 3 import ( 4 "fmt" 5 6 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors" 7 ) 8 9 var errSyntax = xerrors.Wrap(fmt.Errorf("invalid syntax")) 10 11 type ParseError struct { 12 Err error 13 Input string 14 } 15 16 func (p *ParseError) Error() string { 17 return fmt.Sprintf( 18 "decimal: parse %q: %v", p.Input, p.Err, 19 ) 20 } 21 22 func (p *ParseError) Unwrap() error { 23 return p.Err 24 } 25 26 func syntaxError(s string) *ParseError { 27 return &ParseError{ 28 Err: errSyntax, 29 Input: s, 30 } 31 } 32 33 func precisionError(s string, precision, scale uint32) *ParseError { 34 return &ParseError{ 35 Err: fmt.Errorf("invalid precision/scale: %d/%d", precision, scale), 36 Input: s, 37 } 38 }