Metadata-Version: 2.1
Name: drf-standardized-errors
Version: 0.10.0
Summary: Standardize your API error responses.
Keywords: standardized errors,errors formatter,django rest framework
Author: Ghazi Abbassi
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: django >=3.2
Requires-Dist: djangorestframework >=3.12
Requires-Dist: pre-commit ; extra == "dev"
Requires-Dist: sphinx ; extra == "doc"
Requires-Dist: sphinx-autobuild ; extra == "doc"
Requires-Dist: sphinx-rtd-theme ; extra == "doc"
Requires-Dist: myst-parser ; extra == "doc"
Requires-Dist: flit ; extra == "release"
Requires-Dist: keyring ; extra == "release"
Requires-Dist: tbump ; extra == "release"
Requires-Dist: tox ; extra == "test"
Requires-Dist: tox-gh-actions ; extra == "test"
Project-URL: changelog, https://github.com/ghazi-git/drf-standardized-errors/blob/main/docs/changelog.md
Project-URL: code, https://github.com/ghazi-git/drf-standardized-errors
Project-URL: documentation, https://drf-standardized-errors.readthedocs.io/en/latest/
Project-URL: homepage, https://github.com/ghazi-git/drf-standardized-errors
Project-URL: issues, https://github.com/ghazi-git/drf-standardized-errors/issues
Provides-Extra: dev
Provides-Extra: doc
Provides-Extra: release
Provides-Extra: test

# DRF Standardized Errors

Standardize your [DRF](https://www.django-rest-framework.org/) API error responses.

[![Read the Docs](https://img.shields.io/readthedocs/drf-standardized-errors)](https://drf-standardized-errors.readthedocs.io/en/latest/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ghazi-git/drf-standardized-errors/Tests?label=Tests&logo=GitHub)](https://github.com/ghazi-git/drf-standardized-errors/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/ghazi-git/drf-standardized-errors/branch/main/graph/badge.svg?token=JXTTT1KVBR)](https://codecov.io/gh/ghazi-git/drf-standardized-errors)
[![PyPI](https://img.shields.io/pypi/v/drf-standardized-errors)](https://pypi.org/project/drf-standardized-errors/)
[![PyPI - License](https://img.shields.io/pypi/l/drf-standardized-errors)](LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

By default, the API error responses (4xx and 5xx) will look like:

```json
{
  "type": "validation_error",
  "errors": [
    {
      "code": "required",
      "detail": "This field is required.",
      "attr": "name"
    }
  ]
}
```


## Features

- Highly customizable: gives you flexibility to define your own standardized error responses and override
specific aspects the exception handling process without having to rewrite everything.
- Supports nested serializers and ListSerializer errors
- Plays nicely with error monitoring tools (like Sentry, ...)


## Requirements

- python >= 3.8
- Django >= 3.2
- DRF >= 3.12


## Quickstart

Install with `pip`
```shell
pip install drf-standardized-errors
```

Add drf-standardized-errors to your installed apps
```python
INSTALLED_APPS = [
    # other apps
    "drf_standardized_errors",
]
```

Register the exception handler
```python
REST_FRAMEWORK = {
    # other settings
    "EXCEPTION_HANDLER": "drf_standardized_errors.exception_handler"
}
```

### Notes
Standardized error responses when `DEBUG=True` for **unhandled exceptions** are disabled by default. That is
to allow you to get more information out of the traceback. You can enable standardized errors instead with:
```python
DRF_STANDARDIZED_ERRORS = {"ENABLE_IN_DEBUG_FOR_UNHANDLED_EXCEPTIONS": True}
```


## Links

- Documentation: https://drf-standardized-errors.readthedocs.io/en/latest/
- Changelog: https://github.com/ghazi-git/drf-standardized-errors/blob/main/docs/changelog.md
- Code & issues: https://github.com/ghazi-git/drf-standardized-errors
- PyPI: https://pypi.org/project/drf-standardized-errors/


## Licence

This project is [MIT licensed](LICENSE).

