# Path: esc/oops.py
# class ProgrammingError(EscError):
#     r"""
#     Indicates an error caused by incorrectly written or defined esc
#     plugins. This includes modes, menus, operations, and so on.
#     It does not include runtime errors within operation functions
#     themselves; these are :class:`FunctionExecutionError`\ s.
#     """


from .oops import ProgrammingError
        return self._value

    @value.setter
    def value(self, val):
        if self.allowable_values is not None and val not in self.allowable_values:
            raise ProgrammingError(f"Tried to set invalid mode {val} "
                                   f"(valid values: {','.join(self.allowable_values)})")
        self._value = val


def get(name):
    """
    Retrieve the value of a mode with a given name. Return None if no mode by
    that name has been registered.
    """
    try:
        return MODES[name].value
    except KeyError:
        return None


def register(name, default_value, allowable_values=None):
    """
    Create a new mode. If the mode already exists,
    a :class:`ProgrammingError <esc.oops.ProgrammingError>` is raised.

    Modes should be registered by the :func:`esc.commands.Mode` factory function,
    not by calling this function directly.
    """
    if name in MODES:

# Path: esc/oops.py
# class ProgrammingError(EscError):
#     r"""
#     Indicates an error caused by incorrectly written or defined esc
#     plugins. This includes modes, menus, operations, and so on.
#     It does not include runtime errors within operation functions
#     themselves; these are :class:`FunctionExecutionError`\ s.
#     """


# Path: esc/modes.py
from .oops import ProgrammingError

        return self._value

    @value.setter
    def value(self, val):
        if self.allowable_values is not None and val not in self.allowable_values:
            raise ProgrammingError(f"Tried to set invalid mode {val} "
                                   f"(valid values: {','.join(self.allowable_values)})")
        self._value = val


def get(name):
    """
    Retrieve the value of a mode with a given name. Return None if no mode by
    that name has been registered.
    """
    try:
        return MODES[name].value
    except KeyError:
        return None


def register(name, default_value, allowable_values=None):
    """
    Create a new mode. If the mode already exists,
    a :class:`ProgrammingError <esc.oops.ProgrammingError>` is raised.

    Modes should be registered by the :func:`esc.commands.Mode` factory function,
    not by calling this function directly.
    """
    if name in MODES:

        raise ProgrammingError("Tried to re-register an existing mode {name}.")