Skip to main content

Throwing web exceptions like in AioHTTP

Project description

https://badge.fury.io/py/django-web-exceptions.svg https://travis-ci.org/samael500/web-exceptions.svg?branch=master https://codecov.io/gh/samael500/web-exceptions/branch/master/graph/badge.svg

Throwing web exceptions like in AioHTTP

What and why?

In AioHTTP you cat raise any response as exception (this is very cool). But Django can raise only 3+1 web exceptions.

This package allow you to raise as exception any on HTTP response.

Quickstart

Install Django Web Exceptions:

pip install django-web-exceptions

Add it to your MIDDLEWARE:

MIDDLEWARE = (
    # ...
    'web_exceptions.middleware.WebExceptionsMiddleware',
    # ...
)

Features

Import exceptions and raise anywhere

from web_exceptions import exceptions

# ...

def index(request):
    """ Simple view raise redirectexception """
    raise exceptions.HTTPMovedPermanently('/foo')

Also you cat customize any kind of exception status code as custom handler, defined in urls.py like django error handlers .

# urls.py

from myapp import views

handler300 = <callable view>
handler400 = <callable view>
handler<status_code> = <callable view>

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

History

0.1.0 (2017-05-13)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-web-exceptions-0.1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_web_exceptions-0.1.0-py2.py3-none-any.whl (7.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-web-exceptions-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-web-exceptions-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cabfbf117a76325fae12ebe9a12c811ef96de6a5a28242f019fbb193ef60a853
MD5 938862c44d5e9b08a8ec5cd141004b92
BLAKE2b-256 e2493ea50aed80342a1d34d3c37256c78bc32d9bcef0d4bd7658c716334c15d1

See more details on using hashes here.

File details

Details for the file django_web_exceptions-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_web_exceptions-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 df6f236ac41449d1e4ec380b229d87d32d8bfd1d9dc60abb531d71c8a98a89df
MD5 f17eec0fd09e18f62f4a835604f1be49
BLAKE2b-256 f7d986389639efc18a4b713f51b1d4056757efa773b2b91da28b0e4a05122145

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page