From 9cdf252cdfbb782ee5afa3da09ea80d27aa71072 Mon Sep 17 00:00:00 2001 From: Everton Moreth Date: Mon, 6 Jul 2015 15:43:25 -0300 Subject: [PATCH] Poor's man fix for non-descriptive error message This is a simple attempt to at least show the right message when rendering an error message. Probably lots can be done to improve this approach, but now it saves me from errors that does not mean anything. --- rest_framework/response.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/response.py b/rest_framework/response.py index 47d947655..97e42e07c 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -43,6 +43,9 @@ class Response(SimpleTemplateResponse): media_type = getattr(self, 'accepted_media_type', None) context = getattr(self, 'renderer_context', None) + if isinstance(self.data, dict) and self.data.get('error', False): + raise self.data['content'] + assert renderer, ".accepted_renderer not set on Response" assert media_type, ".accepted_media_type not set on Response" assert context, ".renderer_context not set on Response"