PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/restlayer/exc.py

https://bitbucket.org/cedarlab/django-restlayer
Python | 22 lines | 15 code | 3 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
 6from django.http import HttpResponse
 7
 8class HttpException(Exception):
 9    def __init__(self, msg, status=500):
10        super(HttpException, self).__init__(msg, status)
11    
12class Http406(HttpException):
13    def __init__(self):
14        super(HttpException, self).__init__('', 406)
15
16class FormErrors(dict):
17    pass
18
19class FormValidationError(HttpException):
20    def __init__(self, form):
21        super(FormValidationError, self).__init__(FormErrors(form.errors), 400)
22