Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that BotServerError.message is properly returned. #1096

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions boto/exception.py
Expand Up @@ -93,9 +93,9 @@ def __init__(self, status, reason, body=None, *args):
self.error_message = self.body
self.body = None

self.message = self.error_message

def __getattr__(self, name):
if name == 'message':
return self.error_message
if name == 'code':
return self.error_code
raise AttributeError
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions tests/unit/exceptions/test_server_error.py
@@ -0,0 +1,15 @@
try:
import unittest2 as unittest
except ImportError:
import unittest

from boto.exception import BotoServerError

class BotoServerErrorTest(unittest.TestCase):
def setUp(self):
self.body = """<?xml version="1.0" encoding="UTF-8"?><Error><Code>NoSuchKey</Code><Message>The resource you requested does not exist</Message><Resource>/mybucket/myfoto.jpg</Resource> <RequestId>4442587FB7D0A2F9</RequestId></Error>"""

def test_exception_message(self):
e = BotoServerError(404, "No Such Key", body=self.body)
self.assertEqual("NoSuchKey", e.code)
self.assertEqual("The resource you requested does not exist", e.message)