def validate_handler(handler, required):
    """
    Raises a ValueError exception when a required is handler but not present.
    """
    if required and handler is None:
        raise ValueError('This socket requires a handler!')
