diff options
| author | Anthony Young <sleepsonthefloor@gmail.com> | 2011-03-18 05:11:06 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-03-18 05:11:06 +0000 |
| commit | abe147f756f13d4f968aa075d709e5c6643d310a (patch) | |
| tree | 2daf7096550708b60ed0ad8efebe8ff5c3a9c340 | |
| parent | e27dc1168c8061c43b3cc64cc10e8a31a37ba39e (diff) | |
| parent | e2d66aaa670817bda9bf1b494b6a4cfde32b6daf (diff) | |
| download | nova-abe147f756f13d4f968aa075d709e5c6643d310a.tar.gz nova-abe147f756f13d4f968aa075d709e5c6643d310a.tar.xz nova-abe147f756f13d4f968aa075d709e5c6643d310a.zip | |
Make "ApiError" the default error code for ApiError instances, rather than "Unknown."
Note Dashoard's error handling code:
except boto.exception.BotoServerError, e:
if e.status == 400 and e.error_code == 'ApiError':
raise NovaApiError(e)
elif e.status == 401:
raise NovaUnauthorizedError()
elif e.status == 503:
raise NovaUnavailableError(e)
raise NovaServerError(e)
So an error_code of 'Unknown' will raise an ugly exception.
This change also makes the euca errors a bit prettier:
> euca-attach-volume -i i-1 vol-2 -d /dev/vdb
> ApiError: ApiError: Volume status must be available
Rather than:
> euca-attach-volume -i i-1 vol-2 -d /dev/vdb
> Unknown: Unknown: Volume status must be available
Though the reiteration of the error code is still a bit ugly.
| -rw-r--r-- | nova/exception.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/nova/exception.py b/nova/exception.py index 93c5fe3d7..4e2bbdbaf 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -46,7 +46,7 @@ class Error(Exception): class ApiError(Error): - def __init__(self, message='Unknown', code='Unknown'): + def __init__(self, message='Unknown', code='ApiError'): self.message = message self.code = code super(ApiError, self).__init__('%s: %s' % (code, message)) |
