{"record":{"id":"334b85ee13bdbd18","repo":"Textualize/textual","slug":"no-mode-called-mode-r","errorCode":null,"errorMessage":"No mode called {mode!r}","messagePattern":"No mode called (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"src/textual/app.py","lineNumber":1267,"sourceCode":"\n    def get_screen_stack(self, mode: str | None = None) -> list[Screen]:\n        \"\"\"Get the screen stack for the given mode, or the current mode if no mode is specified.\n\n        Args:\n            mode: Name of a model\n\n        Raises:\n            KeyError: If there is no mode.\n\n        Returns:\n            A list of screens. Note that this is a copy, and modifying the list will not impact the app's screen stack.\n        \"\"\"\n        if mode is None:\n            mode = self._current_mode\n        try:\n            stack = self._screen_stacks[mode]\n        except KeyError:\n            raise KeyError(f\"No mode called {mode!r}\") from None\n        return stack.copy()\n\n    def exit(\n        self,\n        result: ReturnType | None = None,\n        return_code: int = 0,\n        message: RenderableType | None = None,\n    ) -> None:\n        \"\"\"Exit the app, and return the supplied result.\n\n        Args:\n            result: Return value.\n            return_code: The return code. Use non-zero values for error codes.\n            message: Optional message to display on exit.\n        \"\"\"\n        self._exit = True\n        self._return_value = result\n        self._return_code = return_code","sourceCodeStart":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/app.py#L1249-L1285","documentation":"KeyError raised by App.get_screen_stack(mode) when the requested mode name has no associated screen stack — i.e. the mode was never registered via MODES or add_mode, or was removed.","triggerScenarios":"Calling app.get_screen_stack(\"editor\") when 'editor' is not in app._screen_stacks; querying a removed mode.","commonSituations":"Typos in mode names; querying a mode before switching to it; accessing a mode removed with remove_mode().","solutions":["Check mode in app._modes / use switch_mode first so the stack exists","Verify the exact spelling against MODES keys or add_mode calls"],"exampleFix":"# before\nstack = app.get_screen_stack(\"edtior\")  # typo\n\n# after\nawait app.switch_mode(\"editor\")\nstack = app.get_screen_stack(\"editor\")","handlingStrategy":"validation","validationCode":"if mode not in app._modes:\n    raise ValueError(f'unknown mode {mode}')\n# else stack exists after switch","typeGuard":null,"tryCatchPattern":"try:\n    stack = app.get_screen_stack(mode)\nexcept KeyError:\n    await app.switch_mode(mode)\n    stack = app.get_screen_stack(mode)","preventionTips":["Centralize mode-name constants","switch_mode before inspecting a mode's stack"],"tags":["modes","screen-stack","keyerror","textual"],"backgroundTag":"unknown-mode-requested","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}