Return response code 500, when rendering error.

Responses by the ShowErrorsMiddleware returned response code 200, which confused my JavaScript code. The attached commit sets a 500 response code, making sure the error can be correctly handled on the client-side.

This is my second attempt to create a pull request which only contains the relevant changes. I'm sorry for the inconvenience.