-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathdatastore_errors.py
More file actions
executable file
·159 lines (108 loc) · 4.25 KB
/
Copy pathdatastore_errors.py
File metadata and controls
executable file
·159 lines (108 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python
#
# Copyright 2007 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Errors used in the Python datastore API."""
class Error(Exception):
"""Base datastore error type.
"""
class BadValueError(Error):
"""Raised by `Entity.__setitem__()`, `Query.__setitem__()`, `Get()`, and others.
Occurs when a property value or filter value is invalid.
"""
class BadPropertyError(Error):
"""Raised by `Entity.__setitem__()` when a property name isn't a string.
"""
class BadRequestError(Error):
"""Raised by datastore calls when the parameter(s) are invalid.
"""
class EntityNotFoundError(Error):
"""DEPRECATED: Raised by `Get()` when the requested entity is not found.
"""
class BadArgumentError(Error):
"""Raised by `Query.Order()`, `Iterator.Next()`, and others when they're passed an invalid argument.
"""
class QueryNotFoundError(Error):
"""DEPRECATED: Raised by Iterator methods when the Iterator is invalid.
This should not happen during normal usage; it protects against malicious
users and system errors.
"""
class TransactionNotFoundError(Error):
"""DEPRECATED: Raised by `RunInTransaction`.
This is an internal error; you should not see this.
"""
class Rollback(Error):
"""May be raised by transaction functions when they want to roll back instead of committing.
Note that *any* exception raised by a transaction function will cause a
rollback. This is purely for convenience. See
`datastore.RunInTransaction` for details.
"""
class TransactionFailedError(Error):
"""Raised by `RunInTransaction` methods when the transaction could not be committed, even after retrying.
This is usually due to high contention.
"""
class BadFilterError(Error):
"""Raised by `Query.__setitem__()` and `Query.Run()` when a filter string is invalid.
"""
def __init__(self, filter):
self.filter = filter
message = (u'invalid filter: %s.' % self.filter).encode('utf-8')
super(BadFilterError, self).__init__(message)
class BadQueryError(Error):
"""Raised by `Query` when a query or query string is invalid.
"""
class SnapshotVersionTooOldError(Error):
"""Raised by `Query` when a snapshot is too old and no longer exists.
Internal.
"""
class BadKeyError(Error):
"""Raised by `Key.__str__` when the key is invalid.
"""
class InternalError(Error):
"""An internal datastore error. Please report this to Google.
"""
class NeedIndexError(Error):
"""No matching index was found for a query that requires an index.
Check the Indexes page in the Admin Console and your `index.yaml` file.
"""
def __init__(self, error, original_message=None, header=None, yaml_index=None,
xml_index=None):
super(NeedIndexError, self).__init__(error)
self._original_message = original_message
self._header = header
self._yaml_index = yaml_index
self._xml_index = xml_index
def OriginalMessage(self):
return self._original_message
def Header(self):
return self._header
def YamlIndex(self):
return self._yaml_index
def XmlIndex(self):
return self._xml_index
class ReferencePropertyResolveError(Error):
"""An error occurred while trying to resolve a `ReferenceProperty`."""
class Timeout(Error):
"""The datastore operation timed out, or the data was temporarily unavailable.
This can happen when you attempt to put, get, or delete too many entities or
an entity with too many properties, or if the datastore is overloaded or
having trouble.
"""
class CommittedButStillApplying(Timeout):
"""The write or transaction was committed, but some entities or index rows may not have been fully updated.
Those updates should automatically be
applied soon. You can roll them forward immediately by reading one of the
entities inside a transaction.
"""