1 // Copyright 2011 Google Inc. All rights reserved.
2 // Use of this source code is governed by the Apache 2.0
3 // license that can be found in the LICENSE file.
5 // This file provides error functions for common API failure modes.
12 "google.golang.org/appengine/internal"
15 // IsOverQuota reports whether err represents an API call failure
16 // due to insufficient available quota.
17 func IsOverQuota(err error) bool {
18 callErr, ok := err.(*internal.CallError)
19 return ok && callErr.Code == 4
22 // MultiError is returned by batch operations when there are errors with
23 // particular elements. Errors will be in a one-to-one correspondence with
24 // the input elements; successful elements will have a nil entry.
25 type MultiError []error
27 func (m MultiError) Error() string {
43 return s + " (and 1 other error)"
45 return fmt.Sprintf("%s (and %d other errors)", s, n-1)