thirdparty/google_appengine/google/appengine/api/datastore_errors.py
changeset 109 620f9b141567
equal deleted inserted replaced
108:261778de26ff 109:620f9b141567
       
     1 #!/usr/bin/env python
       
     2 #
       
     3 # Copyright 2007 Google Inc.
       
     4 #
       
     5 # Licensed under the Apache License, Version 2.0 (the "License");
       
     6 # you may not use this file except in compliance with the License.
       
     7 # You may obtain a copy of the License at
       
     8 #
       
     9 #     http://www.apache.org/licenses/LICENSE-2.0
       
    10 #
       
    11 # Unless required by applicable law or agreed to in writing, software
       
    12 # distributed under the License is distributed on an "AS IS" BASIS,
       
    13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    14 # See the License for the specific language governing permissions and
       
    15 # limitations under the License.
       
    16 #
       
    17 
       
    18 """Errors used in the Python datastore API."""
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 class Error(Exception):
       
    26   """Base datastore error type.
       
    27   """
       
    28 
       
    29 class BadValueError(Error):
       
    30   """Raised by Entity.__setitem__(), Query.__setitem__(), Get(), and others
       
    31   when a property value or filter value is invalid.
       
    32   """
       
    33 
       
    34 class BadPropertyError(Error):
       
    35   """Raised by Entity.__setitem__() when a property name isn't a string.
       
    36   """
       
    37 
       
    38 class BadRequestError(Error):
       
    39   """Raised by datastore calls when the parameter(s) are invalid.
       
    40   """
       
    41 
       
    42 class EntityNotFoundError(Error):
       
    43   """DEPRECATED: Raised by Get() when the requested entity is not found.
       
    44   """
       
    45 
       
    46 class BadArgumentError(Error):
       
    47   """Raised by Query.Order(), Iterator.Next(), and others when they're
       
    48   passed an invalid argument.
       
    49   """
       
    50 
       
    51 class QueryNotFoundError(Error):
       
    52   """DEPRECATED: Raised by Iterator methods when the Iterator is invalid. This
       
    53   should not happen during normal usage; it protects against malicious users
       
    54   and system errors.
       
    55   """
       
    56 
       
    57 class TransactionNotFoundError(Error):
       
    58   """DEPRECATED: Raised by RunInTransaction. This is an internal error; you
       
    59   should not see this.
       
    60   """
       
    61 
       
    62 class Rollback(Error):
       
    63   """May be raised by transaction functions when they want to roll back
       
    64   instead of committing. Note that *any* exception raised by a transaction
       
    65   function will cause a rollback. This is purely for convenience. See
       
    66   datastore.RunInTransaction for details.
       
    67   """
       
    68 
       
    69 class TransactionFailedError(Error):
       
    70   """Raised by RunInTransaction methods when the transaction could not be
       
    71   committed, even after retrying. This is usually due to high contention.
       
    72   """
       
    73 
       
    74 class BadFilterError(Error):
       
    75   """Raised by Query.__setitem__() and Query.Run() when a filter string is
       
    76   invalid.
       
    77   """
       
    78   def __init__(self, filter):
       
    79     self.filter = filter
       
    80 
       
    81   def __str__(self):
       
    82     return (u'BadFilterError: invalid filter: %s.' % self.filter)
       
    83 
       
    84 class BadQueryError(Error):
       
    85   """Raised by Query when a query or query string is invalid.
       
    86   """
       
    87 
       
    88 class BadKeyError(Error):
       
    89   """Raised by Key.__str__ when the key is invalid.
       
    90   """
       
    91 
       
    92 class InternalError(Error):
       
    93   """An internal datastore error. Please report this to Google.
       
    94   """
       
    95 
       
    96 class NeedIndexError(Error):
       
    97   """No matching index was found for a query that requires an index. Check
       
    98   the Indexes page in the Admin Console and your index.yaml file.
       
    99   """
       
   100 
       
   101 class Timeout(Error):
       
   102   """The datastore operation timed out. This can happen when you attempt to
       
   103   put, get, or delete too many entities or an entity with too many properties,
       
   104   or if the datastore is overloaded or having trouble.
       
   105   """