1#
2# Copyright 2007 Google LLC. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#    http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16"""Errors thrown by apiproxy.MakeSyncCall.
17"""
18
19
20
21
22class Error(Exception):
23  """Base APIProxy error type."""
24
25
26class RPCFailedError(Error):
27  """Raised by APIProxy calls when the RPC to the application server fails."""
28
29
30class CallNotFoundError(Error):
31  """Raised by APIProxy calls when the requested method cannot be found."""
32
33
34class ArgumentError(Error):
35  """Raised by APIProxy calls if there is an error parsing the arguments."""
36
37
38class DeadlineExceededError(Error):
39  """Raised by APIProxy calls if the call took too long to respond.
40
41  Not to be confused with runtime.DeadlineExceededError.
42  That one is raised when the overall HTTP response deadline is exceeded.
43  """
44
45
46class CancelledError(Error):
47  """Raised by APIProxy calls if the call was cancelled, such as when
48  the user's request is exiting."""
49
50
51class ApplicationError(Error):
52  """Raised by APIProxy in the event of an application-level error."""
53  def __init__(self, application_error, error_detail=''):
54    self.application_error = application_error
55    self.error_detail = error_detail
56    Error.__init__(self, application_error)
57
58  def __str__(self):
59    return 'ApplicationError: %d %s' % (self.application_error,
60                                        self.error_detail)
61
62class OverQuotaError(Error):
63  """Raised by APIProxy calls when they have been blocked due to a lack of
64  available quota."""
65
66
67class RequestTooLargeError(Error):
68  """Raised by APIProxy calls if the request was too large."""
69
70
71class ResponseTooLargeError(Error):
72  """Raised by APIProxy calls if the response was too large."""
73
74
75class CapabilityDisabledError(Error):
76  """Raised by APIProxy when API calls are temporarily disabled."""
77
78
79class FeatureNotEnabledError(Error):
80  """Raised by APIProxy when the app must enable a feature to use this call."""
81
82
83class InterruptedError(Error):
84  """Raised by APIProxy.Wait() when the wait is interrupted by an uncaught
85  exception from some callback, not necessarily associated with the RPC in
86  question."""
87  def __init__(self, exception, rpc):
88    self.args = ("The Wait() request was interrupted by an exception from "
89                 "another callback:", exception)
90    self.__rpc = rpc
91    self.__exception = exception
92
93  @property
94  def rpc(self):
95    return self.__rpc
96
97  @property
98  def exception(self):
99    return self.__exception
100
101
102class RpcAuthorityError(Error):
103  """Raised by APIProxy when loading rpc authority from the environment."""
104