Home | History | Annotate | Download | only in shared
      1 from django import http
      2 
      3 class RequestError(Exception):
      4     """Signifies that an error response should be returned."""
      5 
      6     def __init__(self, code, entity_body=''):
      7         if not entity_body.endswith('\n'):
      8             entity_body += '\n'
      9         self.response = http.HttpResponse(entity_body, status=code)
     10 
     11 
     12 class BadRequest(RequestError):
     13     """An error was found with the request, 400 Bad Request will be returned.
     14 
     15     The exception string should contain a description of the error.
     16     """
     17 
     18     def __init__(self, description):
     19         super(BadRequest, self).__init__(400, description)
     20