def _identity_error_message(msg_type, message, status_code, request):
    """
    Set the response code on the request, and return a JSON blob representing
    a Identity error body, in the format Identity returns error messages.

    :param str msg_type: What type of error this is - something like
        "badRequest" or "itemNotFound" for Identity.
    :param str message: The message to include in the body.
    :param int status_code: The status code to set
    :param request: the request to set the status code on

    :return: dictionary representing the error body
    """
    request.setResponseCode(status_code)
    return {msg_type: {'message': message, 'code': status_code}}
