/restlayer/exc.py

https://bitbucket.org/cedarlab/django-restlayer · Python · 22 lines · 12 code · 6 blank · 4 comment · 0 complexity · a6ab534eeb9a68fa8b9a41bc18677228 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. #
  3. # This file is part of Django restlayer released under the MIT license.
  4. # See the LICENSE for more information.
  5. from django.http import HttpResponse
  6. class HttpException(Exception):
  7. def __init__(self, msg, status=500):
  8. super(HttpException, self).__init__(msg, status)
  9. class Http406(HttpException):
  10. def __init__(self):
  11. super(HttpException, self).__init__('', 406)
  12. class FormErrors(dict):
  13. pass
  14. class FormValidationError(HttpException):
  15. def __init__(self, form):
  16. super(FormValidationError, self).__init__(FormErrors(form.errors), 400)