appengine/v2/errors.go

47 строки
1.1 KiB
Go
Исходник Постоянная ссылка Обычный вид История

Merge QA into the main branch (#247) * Removing old, unsupported APIs (#230) * Remove the old Search API. * Remove the old Remote API. * Remove the old sockets API. * Delete legacy appengine code (#231) - Delete all files behind `+build appengine` - Merge the `*_vm.go` variants with the base files - `go fix` for context update (TODO: Fix internal/api.go's use of context) - Update travis config to test new versions * Remove Query APIs from appengine.log (#233) Remove deprecated log.Query api from appengine.log * Update docs (#234) * Remove the old Search API. * Remove the old Remote API. * Remove the old sockets API. * Temporarily remove blobstore API for v2 preview. * Revert "Temporarily remove blobstore API for v2 preview." This reverts commit 169bbdd4674a0fc862fd6a12a843eb2b3bba01cd. * Update docs for QA. * Update module API docs to indicate manual_scaling must be used for NumInstances, etc. * Update module API docs to indicate manual_scaling must be used for NumInstances, etc. * Remove old interfaces and interfaces that are not recommended (#236) * Remove the old deprecated channel interface. * Remove the old deprecated file interface. * Remove the old deprecated xmpp interface. * Removing the cloudsql interface, which is not recommended. * Removing the aebundler interface, which has been deprecated for some time. * Remove obsolete demo code (#238) * Remove obsolete demo code. Official appengine sample code referred by doc is in https://github.com/GoogleCloudPlatform/golang-samples * Replace Logs API with Stdout (#240) * Removed Logs API. * Remove dead code. * Added JSON encoding tests. * Emit single character severity in JSON message to trigger structured logs handling. * Prevent timestamp from being emitted on deployed logs. * Remove superfluous apis (#241) * Removed protos for channel/search/xmpp. * Remove protos for socket. * Add traceID/spanID to structured logs and chunk long logs (#242) * Moved logging related logic to separate file. * Added traceID/spanID to structured logs and log chunking. * Changes from code review. * Update go.mod for v2 * Revert v2 in the base directory. * Create the v2 in /v2 and revert the base directory back to 1.6.7 (#243) * Create a v2 directory for v2+ releases. * Update AppEngine imports to v2. * Update AppEngine imports to v2. * Clean up travis. We only currently support go 1.11+ * Temporarily disable testing go111+ with gopath until we can tag v2 properly. * Tidy v2/go.mod (#244) * Create a v2 directory for v2+ releases. * Update AppEngine imports to v2. * Update AppEngine imports to v2. * Clean up travis. We only currently support go 1.11+ * Temporarily disable testing go111+ with gopath until we can tag v2 properly. * Tidy go.sum * go mod tidy (#245) * Create a v2 directory for v2+ releases. * Update AppEngine imports to v2. * Update AppEngine imports to v2. * Clean up travis. We only currently support go 1.11+ * Temporarily disable testing go111+ with gopath until we can tag v2 properly. * Tidy go.sum * go mod tidy Co-authored-by: Steven Buss <sbuss@google.com> Co-authored-by: Kayla Nguyen <kaylanguyen@google.com> Co-authored-by: Jason Collins <jason.a.collins@gmail.com>
2021-06-15 20:57:49 +03:00
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
// This file provides error functions for common API failure modes.
package appengine
import (
"fmt"
"google.golang.org/appengine/v2/internal"
)
// IsOverQuota reports whether err represents an API call failure
// due to insufficient available quota.
func IsOverQuota(err error) bool {
callErr, ok := err.(*internal.CallError)
return ok && callErr.Code == 4
}
// MultiError is returned by batch operations when there are errors with
// particular elements. Errors will be in a one-to-one correspondence with
// the input elements; successful elements will have a nil entry.
type MultiError []error
func (m MultiError) Error() string {
s, n := "", 0
for _, e := range m {
if e != nil {
if n == 0 {
s = e.Error()
}
n++
}
}
switch n {
case 0:
return "(0 errors)"
case 1:
return s
case 2:
return s + " (and 1 other error)"
}
return fmt.Sprintf("%s (and %d other errors)", s, n-1)
}