It might be worth it to look into custom error handling at this point. I tried mocking out a class, this seemed to work:

```python
from werkzeug.exceptions import HTTPException
from werkzeug.wrappers import BaseResponse

class MongoWSServerError(HTTPException):
    def __init__(self, message, code):
        self.code = code
        self.message = message

    def get_body(self, environ):
        return dumps({
            'error': self.code,
            'reason': self.message,
            'detail': ''
        })

    def get_response(self, environ):
        headers = [('Content-Type', 'application/json')]
        return BaseResponse(self.get_body(environ), self.code, headers)
```

You use it normally: ```raise MongoWSServerError(e.message, 500)```. Anyway, this might clean up the code a bit. I guess it doesn't have to be in this pull request, but it would nice to clean this duplicated code up with a method as well as replace any other places where we throw an exception with this (for instance parse_get_json).