django-annoying icon indicating copy to clipboard operation
django-annoying copied to clipboard

Enchance exception middleware and support richer exception hierarchy

Open cezio opened this issue 11 years ago • 1 comments

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.

cezio avatar Jul 04 '13 09:07 cezio

Hmm, can you post some sample code to illustrate this use case? I'm not clear on what use case it would serve. Thanks!

skorokithakis avatar Jul 04 '13 11:07 skorokithakis