1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
# Copyright [2010] [Anso Labs, LLC]
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
8
# http://www.apache.org/licenses/LICENSE-2.0
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.
17
Nova base exception handling, including decorator for re-raising
18
Nova-type exceptions. SHOULD include dedicated exception logging.
25
class Error(Exception):
28
class ApiError(Error):
29
def __init__(self, message='Unknown', code='Unknown'):
30
self.message = message
33
class NotFound(Error):
36
class NotAuthorized(Error):
39
def wrap_exception(f):
40
def _wrap(*args, **kw):
44
if not isinstance(e, Error):
45
# exc_type, exc_value, exc_traceback = sys.exc_info()
46
logging.exception('Uncaught exception')
47
# logging.debug(traceback.extract_stack(exc_traceback))
50
_wrap.func_name = f.func_name