Adds a new JSONFail function

Sends a JSON object to the client and also attaches an error to the current context