diff options
author | moraes <rodrigo.moraes@gmail.com> | 2012-10-13 21:05:18 +0400 |
---|---|---|
committer | moraes <rodrigo.moraes@gmail.com> | 2012-10-13 21:05:18 +0400 |
commit | 74772485ec34b39cc2641ddcd3fa6f68553b1d4b (patch) | |
tree | 016139b4ca714ff547a9fb13a6aae7ed903dcda1 | |
parent | aaee2300ed56f2b0fa93ec1fb3510fa9f86b3e57 (diff) |
Use the same MultiError version from the App Engine SDK.
-rw-r--r-- | securecookie.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/securecookie.go b/securecookie.go index e997fbd..ce5d09f 100644 --- a/securecookie.go +++ b/securecookie.go @@ -395,13 +395,16 @@ func DecodeMulti(name string, value string, dst interface{}, type MultiError []error func (m MultiError) Error() string { - s := "" - for k, v := range m { - if v != nil && k == 0 { - s = v.Error() + s, n := "", 0 + for _, e := range m { + if e != nil { + if n == 0 { + s = e.Error() + } + n++ } } - switch len(m) { + switch n { case 0: return "(0 errors)" case 1: @@ -409,5 +412,5 @@ func (m MultiError) Error() string { case 2: return s + " (and 1 other error)" } - return fmt.Sprintf("%s (and %d other errors)", s, len(m)-1) + return fmt.Sprintf("%s (and %d other errors)", s, n-1) } |