def _object_under_constuction_check(c):
    """
    A helper function to raise an exception if an object is created while a :class:`lod.basics.MessageBuilder` is still unfinished.
    """
    global _object_under_construction_counter
    _object_under_construction_counter += c
    if (c == 0 and _object_under_construction_counter != 0 or c == 1 and 
        _object_under_construction_counter != 1):
        raise ValueError(
            "Can't create another object while a Message is being constructed! Did you forget to call .finish() on a MessageBuilder?"
            )
