Backend: fix exception messaging

This commit is contained in:
medmunds
2012-07-12 17:30:16 -07:00
parent 96b5733e9d
commit c1e577c6f5

View File

@@ -7,20 +7,20 @@ from django.utils import simplejson as json
import requests import requests
class DjrillBackendHTTPError(Exception): class DjrillBackendHTTPError(Exception):
"""An exception that will turn into an HTTP error response.""" """An exception that will turn into an HTTP error response."""
def __init__(self, status_code, log_message=None, *args): def __init__(self, status_code, log_message=None):
self.status_code = status_code super(DjrillBackendHTTPError, self).__init__()
self.log_message = log_message self.status_code = status_code
self.args = args self.log_message = log_message
def __str__(self): def __str__(self):
message = "DjrillBackendHTTP %d: %s" % ( message = "DjrillBackendHTTP %d" % self.status_code
self.status_code, httplib.responses[self.status_code]) if self.log_message:
if self.log_message: return message + " " + self.log_message
return message + " (" + (self.log_message % self.args) + ")" else:
else:
return message return message
class DjrillBackend(BaseEmailBackend): class DjrillBackend(BaseEmailBackend):
""" """
Mandrill API Email Backend Mandrill API Email Backend