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 can 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 of 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 can 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>

For more example see example proj

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.3 (2017-05-15)

  • Fix pypi wrong upload issue.

0.1.2 (2017-05-15)

  • Clean source code from unused rows.

0.1.1 (2017-05-13)

  • Small fixes in source code and readme.

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.3.tar.gz (7.5 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.3-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for django-web-exceptions-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6d10e4226f703c3c0792d7c061488b98c34716a6e200b406ab7c7273c16157dd
MD5 9e254c04c79fd16bf3bb26acfcd6d70c
BLAKE2b-256 e79b8002b0a4c00fcc650be0784195d7feed872ccf4b06beb1d2471ebc04ef4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_web_exceptions-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 06fb66c033238efbeac41f5fad16e4576613345898aec487a31356397e0102eb
MD5 e90039eabc22103105e50abf4959a49e
BLAKE2b-256 d9d63802e2e5034e0baf718a1810ae143649341eae3b31406a04bb22f9b8d450

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