{ "info": { "author": "Hipo", "author_email": "pypi@hipolabs.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Hipo DRF Exceptions\n[![hipo](https://img.shields.io/badge/hipo-red.svg)](https://hipolabs.com) [![Build Status](https://travis-ci.org/Hipo/hipo-drf-exceptions.svg?branch=master)](https://travis-ci.org/Hipo/hipo-drf-exceptions) [![pypi](https://img.shields.io/pypi/v/hipo-drf-exceptions.svg)](https://pypi.org/project/hipo-drf-exceptions/)\n\nA [Django](https://www.djangoproject.com) app for returning consistent, verbose and easy to parse error messages on [Django Rest Framework](https://www.django-rest-framework.org/) backends.\n\nParsing error messages generated by DRF is a bit of pain for client developers. They need to try-catch different possible error formats. When you add errors raised at the business logic level, the error parsing becomes even more difficult. \n\nThis package unifies the output format of DRF in the \"Hipo Error Protocol\". \n\n*No more \"An error occured.\" errors.*\n\nThis package also provides the \"fallback message\", a text string that always contains a human readable error summary. This way, client developers can always fallback and show this message when the client receives an error that is not handled.\n\n> Sounds cool! Can client devs just use this field all the time?\n\nIn our past experience, we noticed that some _lazy_ client developers tend to use this message and avoid writing any code to parse the error bundle. However, the message in this field is automatically generated and may not always be suitable for end users. In order to make clear that this is a *fallback* message, we named this field \"fallback_message\"\n\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Support](#support)\n- [Contributing](#contributing)\n\n## Installation\n\nYou can get stable version of Hipo Excepitons by using pip, pipenv or poetry:\n```\npip install hipo-drf-exceptions\n```\n\n## Usage\n\n### Handler\nYou will need to set `EXCEPTION_HANDLER` of the `REST_FRAMEWORK` setting of your Django project settings.py file.\n```\nREST_FRAMEWORK = {\n ..\n 'EXCEPTION_HANDLER': 'hipo_drf_exceptions.handler',\n}\n```\n\n### Example Error Responses\n\n#### Field Error\n\nHave validations on model level and raise `ValidationError` when it is required.\n```python\nfrom django.core.exceptions import ValidationError\n\nclass Invitation(models.Model):\n email = models.EmailField(unique=True)\n\n def save(self, *args, **kwargs):\n if User.objects.filter(email=self.email).exists():\n raise ValidationError({\"email\": _(\"Email is already registered.\")})\n \n super().save(*args, **kwargs)\n```\n\nIf the view or serializer encounters with the `ValidationError`, The response will be like:\n```json\n{\n \"type\": \"ValidationError\",\n \"detail\": {\n \"email\": [\n \"Email is already registered.\"\n ]\n },\n \"fallback_message\": \"Email is already registered.\"\n}\n```\n\n#### Non Field Error\nImplement your own error classes.\n```python\nfrom hipo_drf_exceptions import BaseAPIException\n\nclass ProfileCredentialError(BaseAPIException):\n default_detail = _('Profile credentials are not correct.')\n```\n\nRaise error when it is required.\n```python\nclass AuthenticationView(GenericAPIView):\n\n def post(self, request, *args, **kwargs):\n ..\n if not profile.check_password(password):\n raise ProfileCredentialError()\n ..\n```\n\nThe response will be like:\n```json\n{\n \"type\": \"ProfileCredentialError\",\n \"detail\": {\n \"non_field_errors\": [\n \"Profile credentials are not correct.\"\n ]\n },\n \"fallback_message\": \"Profile credentials are not correct.\"\n}\n```\n\n## Support\n\nPlease [open an issue](https://github.com/hipo/hipo-drf-exceptions/issues/new) for support.\n\n## Contributing\n\nPlease contribute using [Github Flow](https://guides.github.com/introduction/flow/). Create a branch, add commits, and [open a pull request](https://github.com/hipo/hipo-drf-exceptions/compare/).\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hipo/hipo-drf-exceptions", "keywords": "python,django,django rest framework,error handling,exception", "license": "Apache-2.0", "maintainer": "Hipo", "maintainer_email": "pypi@hipolabs.com", "name": "hipo-drf-exceptions", "package_url": "https://pypi.org/project/hipo-drf-exceptions/", "platform": "", "project_url": "https://pypi.org/project/hipo-drf-exceptions/", "project_urls": { "Homepage": "https://github.com/hipo/hipo-drf-exceptions", "Repository": "https://github.com/hipo/hipo-drf-exceptions" }, "release_url": "https://pypi.org/project/hipo-drf-exceptions/0.1.2/", "requires_dist": [ "djangorestframework (>=3.0)", "Django (>=1.8)" ], "requires_python": ">=2.7", "summary": "A Django app for returning consistent, verbose and easy to parse error messages on Django Rest Framework backends.", "version": "0.1.2" }, "last_serial": 5989892, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1734f4a2afab1924533a1775bcc2792a", "sha256": "73534f5b02951ab75068dfcc72914ffd71f1fbbe91332603a181b74e56caf6af" }, "downloads": -1, "filename": "hipo_drf_exceptions-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "1734f4a2afab1924533a1775bcc2792a", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 12271, "upload_time": "2019-07-03T18:07:56", "url": "https://files.pythonhosted.org/packages/c0/ce/02800f39c5d7aba110cd741b2d783c0355009ed2d88bab82ba7a9353ff5b/hipo_drf_exceptions-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "42f5fe16437e9df2ab9d27aa2bc3b41b", "sha256": "6c81901bbc8972d22c15eec37bb52e00306c82153df67d06fc1faa979caa6cd0" }, "downloads": -1, "filename": "hipo-drf-exceptions-0.1.0.tar.gz", "has_sig": false, "md5_digest": "42f5fe16437e9df2ab9d27aa2bc3b41b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 7799, "upload_time": "2019-07-03T18:07:53", "url": "https://files.pythonhosted.org/packages/b2/ff/d5b4266d0928238525545d6b0291529dd01cc2b893810df72db38d96d33e/hipo-drf-exceptions-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "b61808a0d9da777b4d1bb64ffd86d45c", "sha256": "26563b6bc567b25a368cf532711d8b02ccf9c5dff0efa6bcd7d8a7e05275f979" }, "downloads": -1, "filename": "hipo_drf_exceptions-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b61808a0d9da777b4d1bb64ffd86d45c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 12679, "upload_time": "2019-09-06T08:50:00", "url": "https://files.pythonhosted.org/packages/60/23/a55eb1c992e39c02b7a8479325ca219cdf69ccf851ce8efe63787be444d6/hipo_drf_exceptions-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9440fd9e4c44a00c57b20c2ccb2b5008", "sha256": "26f0c45837547a3955ba94694ac5e62aae80dc283c773f38623f9061f0b457ce" }, "downloads": -1, "filename": "hipo-drf-exceptions-0.1.1.tar.gz", "has_sig": false, "md5_digest": "9440fd9e4c44a00c57b20c2ccb2b5008", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 8198, "upload_time": "2019-09-06T08:49:58", "url": "https://files.pythonhosted.org/packages/b8/c3/5ad5ac24f7f607010f207f951dace4c669a2f64855041f8b2b28fe5bbad5/hipo-drf-exceptions-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "39242285be29adae7496a3d3edba7765", "sha256": "a90172db0241a5b1439c7fb7babfc0615a9802119cf67bf5529bd883a883d26e" }, "downloads": -1, "filename": "hipo_drf_exceptions-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "39242285be29adae7496a3d3edba7765", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 12752, "upload_time": "2019-10-17T13:46:18", "url": "https://files.pythonhosted.org/packages/11/e7/63af1da1176b89ab95dca9aacbd6e4c2a28dff619ed6c6bf91b52cd818c7/hipo_drf_exceptions-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "501fce1462948ca91756f31fa625aa2c", "sha256": "7e753e162dde47d8022c60d8b2c0f2f51ee06719071ea5b24de898b0b41cea56" }, "downloads": -1, "filename": "hipo-drf-exceptions-0.1.2.tar.gz", "has_sig": false, "md5_digest": "501fce1462948ca91756f31fa625aa2c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 8276, "upload_time": "2019-10-17T13:46:17", "url": "https://files.pythonhosted.org/packages/1c/4f/f0d4bcb0807f55aa7bfab24868e26d5b3450d07080b842f56b20ee21c2b9/hipo-drf-exceptions-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "39242285be29adae7496a3d3edba7765", "sha256": "a90172db0241a5b1439c7fb7babfc0615a9802119cf67bf5529bd883a883d26e" }, "downloads": -1, "filename": "hipo_drf_exceptions-0.1.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "39242285be29adae7496a3d3edba7765", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7", "size": 12752, "upload_time": "2019-10-17T13:46:18", "url": "https://files.pythonhosted.org/packages/11/e7/63af1da1176b89ab95dca9aacbd6e4c2a28dff619ed6c6bf91b52cd818c7/hipo_drf_exceptions-0.1.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "501fce1462948ca91756f31fa625aa2c", "sha256": "7e753e162dde47d8022c60d8b2c0f2f51ee06719071ea5b24de898b0b41cea56" }, "downloads": -1, "filename": "hipo-drf-exceptions-0.1.2.tar.gz", "has_sig": false, "md5_digest": "501fce1462948ca91756f31fa625aa2c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7", "size": 8276, "upload_time": "2019-10-17T13:46:17", "url": "https://files.pythonhosted.org/packages/1c/4f/f0d4bcb0807f55aa7bfab24868e26d5b3450d07080b842f56b20ee21c2b9/hipo-drf-exceptions-0.1.2.tar.gz" } ] }