mirror of
https://github.com/kataras/iris.git
synced 2026-01-06 03:27:27 +00:00
Upgrade to new go errors and some minor fixes and improvements including easier debugging of invalid routes and e.t.c.
Former-commit-id: 5809157b952ccc61a67a9861470774b3a6fee024
This commit is contained in:
@@ -11,8 +11,6 @@ import (
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/iris/core/errors"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -102,14 +100,60 @@ func (e Entry) StringTrim() string {
|
||||
return strings.TrimSpace(e.String())
|
||||
}
|
||||
|
||||
var errFindParse = errors.New("unable to find the %s with key: %s")
|
||||
// ErrEntryNotFound may be returned from memstore methods if
|
||||
// a key (with a certain kind) was not found.
|
||||
// Usage:
|
||||
//
|
||||
// var e *ErrEntryNotFound
|
||||
// errors.As(err, &e)
|
||||
// To check for specific key error:
|
||||
// errors.As(err, &ErrEntryNotFound{Key: "key"})
|
||||
// To check for specific key-kind error:
|
||||
// errors.As(err, &ErrEntryNotFound{Key: "key", Kind: reflect.Int})
|
||||
type ErrEntryNotFound struct {
|
||||
Key string // the entry's key.
|
||||
Kind reflect.Kind // i.e bool, int, string...
|
||||
}
|
||||
|
||||
func (e *ErrEntryNotFound) Error() string {
|
||||
return fmt.Sprintf("not found: %s as %s", e.Key, e.Kind.String())
|
||||
}
|
||||
|
||||
// As can be used to manually check if the error came from the memstore
|
||||
// is a not found entry, the key must much in order to return true.
|
||||
// Usage:
|
||||
// errors.As(err, &ErrEntryNotFound{Key: "key", Kind: reflect.Int})
|
||||
//
|
||||
// Do NOT use this method directly, prefer` errors.As` method as explained above.
|
||||
//
|
||||
// Implements: go/src/errors/wrap.go#84
|
||||
func (e *ErrEntryNotFound) As(target interface{}) bool {
|
||||
v, ok := target.(*ErrEntryNotFound)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
if v.Key != "" && v.Key != e.Key {
|
||||
return false
|
||||
}
|
||||
|
||||
if v.Kind != reflect.Invalid && v.Kind != e.Kind {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e Entry) notFound(kind reflect.Kind) *ErrEntryNotFound {
|
||||
return &ErrEntryNotFound{Key: e.Key, Kind: kind}
|
||||
}
|
||||
|
||||
// IntDefault returns the entry's value as int.
|
||||
// If not found returns "def" and a non-nil error.
|
||||
func (e Entry) IntDefault(def int) (int, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("int", e.Key)
|
||||
return def, e.notFound(reflect.Int)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -141,7 +185,7 @@ func (e Entry) IntDefault(def int) (int, error) {
|
||||
return int(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("int", e.Key)
|
||||
return def, e.notFound(reflect.Int)
|
||||
}
|
||||
|
||||
// Int8Default returns the entry's value as int8.
|
||||
@@ -149,7 +193,7 @@ func (e Entry) IntDefault(def int) (int, error) {
|
||||
func (e Entry) Int8Default(def int8) (int8, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("int8", e.Key)
|
||||
return def, e.notFound(reflect.Int8)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -171,7 +215,7 @@ func (e Entry) Int8Default(def int8) (int8, error) {
|
||||
return int8(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("int8", e.Key)
|
||||
return def, e.notFound(reflect.Int8)
|
||||
}
|
||||
|
||||
// Int16Default returns the entry's value as int16.
|
||||
@@ -179,7 +223,7 @@ func (e Entry) Int8Default(def int8) (int8, error) {
|
||||
func (e Entry) Int16Default(def int16) (int16, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("int16", e.Key)
|
||||
return def, e.notFound(reflect.Int16)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -201,7 +245,7 @@ func (e Entry) Int16Default(def int16) (int16, error) {
|
||||
return int16(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("int16", e.Key)
|
||||
return def, e.notFound(reflect.Int16)
|
||||
}
|
||||
|
||||
// Int32Default returns the entry's value as int32.
|
||||
@@ -209,7 +253,7 @@ func (e Entry) Int16Default(def int16) (int16, error) {
|
||||
func (e Entry) Int32Default(def int32) (int32, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("int32", e.Key)
|
||||
return def, e.notFound(reflect.Int32)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -231,7 +275,7 @@ func (e Entry) Int32Default(def int32) (int32, error) {
|
||||
return int32(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("int32", e.Key)
|
||||
return def, e.notFound(reflect.Int32)
|
||||
}
|
||||
|
||||
// Int64Default returns the entry's value as int64.
|
||||
@@ -239,7 +283,7 @@ func (e Entry) Int32Default(def int32) (int32, error) {
|
||||
func (e Entry) Int64Default(def int64) (int64, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("int64", e.Key)
|
||||
return def, e.notFound(reflect.Int64)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -255,7 +299,7 @@ func (e Entry) Int64Default(def int64) (int64, error) {
|
||||
return int64(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("int64", e.Key)
|
||||
return def, e.notFound(reflect.Int64)
|
||||
}
|
||||
|
||||
// UintDefault returns the entry's value as uint.
|
||||
@@ -263,7 +307,7 @@ func (e Entry) Int64Default(def int64) (int64, error) {
|
||||
func (e Entry) UintDefault(def uint) (uint, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("uint", e.Key)
|
||||
return def, e.notFound(reflect.Uint)
|
||||
}
|
||||
|
||||
x64 := strconv.IntSize == 64
|
||||
@@ -279,7 +323,7 @@ func (e Entry) UintDefault(def uint) (uint, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > uint64(maxValue) {
|
||||
return def, errFindParse.Format("uint", e.Key)
|
||||
return def, e.notFound(reflect.Uint)
|
||||
}
|
||||
return uint(val), nil
|
||||
case uint:
|
||||
@@ -292,17 +336,17 @@ func (e Entry) UintDefault(def uint) (uint, error) {
|
||||
return uint(vv), nil
|
||||
case uint64:
|
||||
if vv > uint64(maxValue) {
|
||||
return def, errFindParse.Format("uint", e.Key)
|
||||
return def, e.notFound(reflect.Uint)
|
||||
}
|
||||
return uint(vv), nil
|
||||
case int:
|
||||
if vv < 0 || vv > int(maxValue) {
|
||||
return def, errFindParse.Format("uint", e.Key)
|
||||
return def, e.notFound(reflect.Uint)
|
||||
}
|
||||
return uint(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("uint", e.Key)
|
||||
return def, e.notFound(reflect.Uint)
|
||||
}
|
||||
|
||||
// Uint8Default returns the entry's value as uint8.
|
||||
@@ -310,7 +354,7 @@ func (e Entry) UintDefault(def uint) (uint, error) {
|
||||
func (e Entry) Uint8Default(def uint8) (uint8, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -320,39 +364,39 @@ func (e Entry) Uint8Default(def uint8) (uint8, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(val), nil
|
||||
case uint:
|
||||
if vv > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(vv), nil
|
||||
case uint8:
|
||||
return vv, nil
|
||||
case uint16:
|
||||
if vv > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(vv), nil
|
||||
case uint32:
|
||||
if vv > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(vv), nil
|
||||
case uint64:
|
||||
if vv > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(vv), nil
|
||||
case int:
|
||||
if vv < 0 || vv > math.MaxUint8 {
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
return uint8(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("uint8", e.Key)
|
||||
return def, e.notFound(reflect.Uint8)
|
||||
}
|
||||
|
||||
// Uint16Default returns the entry's value as uint16.
|
||||
@@ -360,7 +404,7 @@ func (e Entry) Uint8Default(def uint8) (uint8, error) {
|
||||
func (e Entry) Uint16Default(def uint16) (uint16, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -370,12 +414,12 @@ func (e Entry) Uint16Default(def uint16) (uint16, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > math.MaxUint16 {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
return uint16(val), nil
|
||||
case uint:
|
||||
if vv > math.MaxUint16 {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
return uint16(vv), nil
|
||||
case uint8:
|
||||
@@ -384,22 +428,22 @@ func (e Entry) Uint16Default(def uint16) (uint16, error) {
|
||||
return vv, nil
|
||||
case uint32:
|
||||
if vv > math.MaxUint16 {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
return uint16(vv), nil
|
||||
case uint64:
|
||||
if vv > math.MaxUint16 {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
return uint16(vv), nil
|
||||
case int:
|
||||
if vv < 0 || vv > math.MaxUint16 {
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
return uint16(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("uint16", e.Key)
|
||||
return def, e.notFound(reflect.Uint16)
|
||||
}
|
||||
|
||||
// Uint32Default returns the entry's value as uint32.
|
||||
@@ -407,7 +451,7 @@ func (e Entry) Uint16Default(def uint16) (uint16, error) {
|
||||
func (e Entry) Uint32Default(def uint32) (uint32, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -417,12 +461,12 @@ func (e Entry) Uint32Default(def uint32) (uint32, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > math.MaxUint32 {
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
return uint32(val), nil
|
||||
case uint:
|
||||
if vv > math.MaxUint32 {
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
return uint32(vv), nil
|
||||
case uint8:
|
||||
@@ -433,19 +477,19 @@ func (e Entry) Uint32Default(def uint32) (uint32, error) {
|
||||
return vv, nil
|
||||
case uint64:
|
||||
if vv > math.MaxUint32 {
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
return uint32(vv), nil
|
||||
case int32:
|
||||
return uint32(vv), nil
|
||||
case int64:
|
||||
if vv < 0 || vv > math.MaxUint32 {
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
return uint32(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("uint32", e.Key)
|
||||
return def, e.notFound(reflect.Uint32)
|
||||
}
|
||||
|
||||
// Uint64Default returns the entry's value as uint64.
|
||||
@@ -453,7 +497,7 @@ func (e Entry) Uint32Default(def uint32) (uint32, error) {
|
||||
func (e Entry) Uint64Default(def uint64) (uint64, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("uint64", e.Key)
|
||||
return def, e.notFound(reflect.Uint64)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -463,7 +507,7 @@ func (e Entry) Uint64Default(def uint64) (uint64, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > math.MaxUint64 {
|
||||
return def, errFindParse.Format("uint64", e.Key)
|
||||
return def, e.notFound(reflect.Uint64)
|
||||
}
|
||||
return uint64(val), nil
|
||||
case uint8:
|
||||
@@ -480,7 +524,7 @@ func (e Entry) Uint64Default(def uint64) (uint64, error) {
|
||||
return uint64(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("uint64", e.Key)
|
||||
return def, e.notFound(reflect.Uint64)
|
||||
}
|
||||
|
||||
// Float32Default returns the entry's value as float32.
|
||||
@@ -488,7 +532,7 @@ func (e Entry) Uint64Default(def uint64) (uint64, error) {
|
||||
func (e Entry) Float32Default(key string, def float32) (float32, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("float32", e.Key)
|
||||
return def, e.notFound(reflect.Float32)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -498,21 +542,21 @@ func (e Entry) Float32Default(key string, def float32) (float32, error) {
|
||||
return def, err
|
||||
}
|
||||
if val > math.MaxFloat32 {
|
||||
return def, errFindParse.Format("float32", e.Key)
|
||||
return def, e.notFound(reflect.Float32)
|
||||
}
|
||||
return float32(val), nil
|
||||
case float32:
|
||||
return vv, nil
|
||||
case float64:
|
||||
if vv > math.MaxFloat32 {
|
||||
return def, errFindParse.Format("float32", e.Key)
|
||||
return def, e.notFound(reflect.Float32)
|
||||
}
|
||||
return float32(vv), nil
|
||||
case int:
|
||||
return float32(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("float32", e.Key)
|
||||
return def, e.notFound(reflect.Float32)
|
||||
}
|
||||
|
||||
// Float64Default returns the entry's value as float64.
|
||||
@@ -520,7 +564,7 @@ func (e Entry) Float32Default(key string, def float32) (float32, error) {
|
||||
func (e Entry) Float64Default(def float64) (float64, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("float64", e.Key)
|
||||
return def, e.notFound(reflect.Float64)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -544,7 +588,7 @@ func (e Entry) Float64Default(def float64) (float64, error) {
|
||||
return float64(vv), nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("float64", e.Key)
|
||||
return def, e.notFound(reflect.Float64)
|
||||
}
|
||||
|
||||
// BoolDefault returns the user's value as bool.
|
||||
@@ -556,7 +600,7 @@ func (e Entry) Float64Default(def float64) (float64, error) {
|
||||
func (e Entry) BoolDefault(def bool) (bool, error) {
|
||||
v := e.ValueRaw
|
||||
if v == nil {
|
||||
return def, errFindParse.Format("bool", e.Key)
|
||||
return def, e.notFound(reflect.Bool)
|
||||
}
|
||||
|
||||
switch vv := v.(type) {
|
||||
@@ -575,7 +619,7 @@ func (e Entry) BoolDefault(def bool) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return def, errFindParse.Format("bool", e.Key)
|
||||
return def, e.notFound(reflect.Bool)
|
||||
}
|
||||
|
||||
// Value returns the value of the entry,
|
||||
@@ -765,7 +809,7 @@ func (r *Store) GetStringTrim(name string) string {
|
||||
func (r *Store) GetInt(key string) (int, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("int", key)
|
||||
return 0, v.notFound(reflect.Int)
|
||||
}
|
||||
return v.IntDefault(-1)
|
||||
}
|
||||
@@ -785,7 +829,7 @@ func (r *Store) GetIntDefault(key string, def int) int {
|
||||
func (r *Store) GetInt8(key string) (int8, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return -1, errFindParse.Format("int8", key)
|
||||
return -1, v.notFound(reflect.Int8)
|
||||
}
|
||||
return v.Int8Default(-1)
|
||||
}
|
||||
@@ -805,7 +849,7 @@ func (r *Store) GetInt8Default(key string, def int8) int8 {
|
||||
func (r *Store) GetInt16(key string) (int16, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return -1, errFindParse.Format("int16", key)
|
||||
return -1, v.notFound(reflect.Int16)
|
||||
}
|
||||
return v.Int16Default(-1)
|
||||
}
|
||||
@@ -825,7 +869,7 @@ func (r *Store) GetInt16Default(key string, def int16) int16 {
|
||||
func (r *Store) GetInt32(key string) (int32, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return -1, errFindParse.Format("int32", key)
|
||||
return -1, v.notFound(reflect.Int32)
|
||||
}
|
||||
return v.Int32Default(-1)
|
||||
}
|
||||
@@ -845,7 +889,7 @@ func (r *Store) GetInt32Default(key string, def int32) int32 {
|
||||
func (r *Store) GetInt64(key string) (int64, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return -1, errFindParse.Format("int64", key)
|
||||
return -1, v.notFound(reflect.Int64)
|
||||
}
|
||||
return v.Int64Default(-1)
|
||||
}
|
||||
@@ -865,7 +909,7 @@ func (r *Store) GetInt64Default(key string, def int64) int64 {
|
||||
func (r *Store) GetUint(key string) (uint, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("uint", key)
|
||||
return 0, v.notFound(reflect.Uint)
|
||||
}
|
||||
return v.UintDefault(0)
|
||||
}
|
||||
@@ -885,7 +929,7 @@ func (r *Store) GetUintDefault(key string, def uint) uint {
|
||||
func (r *Store) GetUint8(key string) (uint8, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("uint8", key)
|
||||
return 0, v.notFound(reflect.Uint8)
|
||||
}
|
||||
return v.Uint8Default(0)
|
||||
}
|
||||
@@ -905,7 +949,7 @@ func (r *Store) GetUint8Default(key string, def uint8) uint8 {
|
||||
func (r *Store) GetUint16(key string) (uint16, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("uint16", key)
|
||||
return 0, v.notFound(reflect.Uint16)
|
||||
}
|
||||
return v.Uint16Default(0)
|
||||
}
|
||||
@@ -925,7 +969,7 @@ func (r *Store) GetUint16Default(key string, def uint16) uint16 {
|
||||
func (r *Store) GetUint32(key string) (uint32, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("uint32", key)
|
||||
return 0, v.notFound(reflect.Uint32)
|
||||
}
|
||||
return v.Uint32Default(0)
|
||||
}
|
||||
@@ -945,7 +989,7 @@ func (r *Store) GetUint32Default(key string, def uint32) uint32 {
|
||||
func (r *Store) GetUint64(key string) (uint64, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return 0, errFindParse.Format("uint64", key)
|
||||
return 0, v.notFound(reflect.Uint64)
|
||||
}
|
||||
return v.Uint64Default(0)
|
||||
}
|
||||
@@ -965,7 +1009,7 @@ func (r *Store) GetUint64Default(key string, def uint64) uint64 {
|
||||
func (r *Store) GetFloat64(key string) (float64, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return -1, errFindParse.Format("float64", key)
|
||||
return -1, v.notFound(reflect.Float64)
|
||||
}
|
||||
return v.Float64Default(-1)
|
||||
}
|
||||
@@ -989,7 +1033,7 @@ func (r *Store) GetFloat64Default(key string, def float64) float64 {
|
||||
func (r *Store) GetBool(key string) (bool, error) {
|
||||
v, ok := r.GetEntry(key)
|
||||
if !ok {
|
||||
return false, errFindParse.Format("bool", key)
|
||||
return false, v.notFound(reflect.Bool)
|
||||
}
|
||||
|
||||
return v.BoolDefault(false)
|
||||
|
||||
Reference in New Issue
Block a user