Chromium Code Reviews

Unified Diff: go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go

Issue 1230303003: Revert "Refactor current GAE abstraction library to be free of the SDK*" (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go
diff --git a/go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go b/go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go
new file mode 100644
index 0000000000000000000000000000000000000000..780787e37e15b094475f9b9e82bd9facfcca1c09
--- /dev/null
+++ b/go/src/infra/gae/libs/wrapper/gae/commonErrors/errors.go
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package commonErrors
+
+import (
+ "reflect"
+
+ "appengine/datastore"
+ "appengine/memcache"
+ "appengine/taskqueue"
+)
+
+// Common errors originating from the GAE SDK
+var (
+ ErrCASConflictMC = memcache.ErrCASConflict
+ ErrNoStatsMC = memcache.ErrNoStats
+ ErrCacheMissMC = memcache.ErrCacheMiss
+ ErrNotStoredMC = memcache.ErrNotStored
+ ErrServerErrorMC = memcache.ErrServerError
+
+ ErrInvalidKeyDS = datastore.ErrInvalidKey
+ ErrConcurrentTransactionDS = datastore.ErrConcurrentTransaction
+ ErrNoSuchEntityDS = datastore.ErrNoSuchEntity
+ ErrInvalidEntityTypeDS = datastore.ErrInvalidEntityType
+
+ ErrTaskAlreadyAddedTQ = taskqueue.ErrTaskAlreadyAdded
+)
+
+// TODO(riannucci): Add common internal errors which originate from the
+// dev_appserver SDK
+
+// ErrFieldMismatchDS returns a datastore.ErrFieldMismatch struct filled with
+// the given specification
+func ErrFieldMismatchDS(structType reflect.Type, fieldName, reason string) error {
+ return &datastore.ErrFieldMismatch{
+ StructType: structType,
+ FieldName: fieldName,
+ Reason: reason,
+ }
+}

Powered by Google App Engine