1. Jesper Noehr
  2. django-piston
  3. Issues
Issue #102 open

Include HTTP error 500 in "rc" responses

José Moreira
created an issue

The library could include HTTP error 500 in "rc" responses, since it's important to distinguish an internal error from a malformed response

Comments (8)

  1. Jesper Noehr repo owner
    • changed status to open

    If there is an Internal Server Error, Django will usually handle it and serve it to the client. I don't think we catch them and do anything with them?

  2. José Moreira reporter

    for example i'm catching exceptions for logging:

    HTTP_INTERNAL_ERROR = HttpResponse('Internal Error', content_type='text/plain', status=500)
    
    except ObjectDoesNotExist:
    	return rc.NOT_FOUND
    except Exception, e:
    	logging.error(e)
    	return HTTP_INTERNAL_ERROR
    
  3. Mario González

    I've seen some Internal Server Error and the full traceback is send to the client not handled by Django. For instance, I wrote a middleware using piston and every error 500 sent a normal Python backtrace only. Anyway, is it a Django bug?

    I think the error 500 must be get caught by Django not Piston.

  4. Anonymous

    I'm interested in being able to catch an exception that happens when a resource handler is running. Right now, they are trapped by Piston and either returned to the client or e-mailed to the admins. I would love to have what josemoreira is doing above, where the exception is logged first.

    Specifically this would make running "./manage.py test" more useful, because the exception would actually be captured in the output if one occurred. Right now if a test fails, I have to re-run the query that cause it to see the error.

  5. Alexis Metaireau
    • changed status to new

    It seems you can specify your proper exceptions by subclassing the error_handler method from the Resource class (located in resource.py).

    Maybe can we set this to fixed ?

  6. Log in to comment