def METHOD_NAME(exception: JsonableError) -> MutableJsonResponse:
    """
    This should only be needed in middleware; in app code, just raise.
    When app code raises a JsonableError, the JsonErrorHandler
    middleware takes care of transforming it into a response by
    calling this function.
    """
    response_type = "error"
    if 200 <= exception.http_status_code < 300:
        response_type = "success"
    response = json_response(
        response_type, msg=exception.msg, data=exception.data, status=exception.http_status_code
    )
    for header, value in exception.extra_headers.items():
        response[header] = value
    return response