Permalink
Browse files

Add RackspaceMonitoringValidationError class.

  • Loading branch information...
1 parent d038bd7 commit ea75f6e356993575304a71567e2147604f63e8a6 @Kami Kami committed Nov 10, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 libcloud/monitoring/drivers/rackspace.py
@@ -36,6 +36,21 @@
API_VERSION = '1.1'
+class RackspaceMonitoringValidationError(LibcloudError):
+
+ def __init__(self, code, type, message, details, driver):
+ self.code = code
+ self.type = type
+ self.message = message
+ self.details = details
+ super(RackspaceMonitoringValidationError, self).__init__(value=message,
+ driver=driver)
+
+ def __str__(self):
+ string = '<ValidationError type=%s, ' % (self.type)
+ string += 'message="%s", details=%s>' % (self.message, self.details)
+ return string
+
class RackspaceMonitoringResponse(Response):
valid_response_codes = [ httplib.NOT_FOUND, httplib.CONFLICT ]
@@ -73,6 +88,18 @@ def parse_body(self):
return data
+ def parse_error(self):
+ body = self.parse_body()
+ if self.status == httplib.BAD_REQUEST:
+ error = RackspaceMonitoringValidationError(message=body['message'],
+ code=body['code'],
+ type=body['type'],
+ details=body['details'],
+ driver=self.connection.driver)
+ return error
+
+ return body
+
class RackspaceMonitoringConnection(OpenStackBaseConnection):
"""

0 comments on commit ea75f6e

Please sign in to comment.