def METHOD_NAME(make_stubber, error_code):
    photo = 's3://doc-example-bucket/test-photo.jpeg'
    prediction = {
        "IsAnomalous": True,
        "Confidence": 0.9,
        "Anomalies": [
            {"Name": "broken"},
            {"Name": "cracked"}
        ]
    }
    confidence_limit = 0.5
    anomaly_types_limit = 1
    if error_code is None:
        Inference.reject_on_anomaly_types(
            photo, prediction, confidence_limit, anomaly_types_limit)
    else:
        prediction = {
            "IsAnomalous": True,
            "Confidence": 0.9,
            "AnomaliesX": [
                {"Name": "broken"},
                {"Name": "cracked"}
            ]
        }
        with pytest.raises(KeyError) as exc_info:
            Inference.reject_on_anomaly_types(
                photo, prediction, confidence_limit, anomaly_types_limit)
        assert exc_info.typename == "KeyError"