<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def json_exception(context, request):
 """Always return json content in the body of Exceptions to xhr requests."""

    request.response.status = context.code
    return {'error': context._status, 'messages': context.message}