django-annoying
django-annoying copied to clipboard
Enchance exception middleware and support richer exception hierarchy
Redirect middleware is a very good idea, but it's usage is quite narrow. It would be good to use more generic approach, with richer exception hierarchy, which would allow to handle other response types.
Sample use case:
- you use CBV
- you check a condition in .get_context(), which is important to any furtner processing in the view,
- condition is not met and all processing should be halted, client should receive some 4xx response
- without such infrastructure, get_context should return dictionary, which should be processed by view, which should check the dict and return error response.
- with such infrastructure you can raise proper exception and handle it the middleware whithout boilerplate code in the view.
Hmm, can you post some sample code to illustrate this use case? I'm not clear on what use case it would serve. Thanks!