{"record":{"id":"6cc141d8c1549238","repo":"JosefNemec/Playnite","slug":"emulator-not-found","errorCode":null,"errorMessage":"Emulator not found.","messagePattern":"Emulator not found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Controllers/GenericGameController.cs","lineNumber":77,"sourceCode":"            IPlayniteAPI playniteApi) : base(game)\r\n        {\r\n            execContext = SynchronizationContext.Current;\r\n            database = db;\r\n            this.scriptRuntime = scriptRuntime;\r\n            this.playniteApi = playniteApi;\r\n        }\r\n\r\n        public override void Play(PlayActionArgs args)\r\n        {\r\n            throw new NotSupportedException(\"This shouldn't be called.\");\r\n        }\r\n\r\n        public void StartEmulator(EmulationPlayAction action, bool asyncExec, OnGameStartingEventArgs startingArgs)\r\n        {\r\n            var emulator = database.Emulators[action.EmulatorId];\r\n            if (emulator == null)\r\n            {\r\n                throw new Exception(\"Emulator not found.\");\r\n            }\r\n\r\n            currentEmuProfile = null;\r\n            if (action.SelectedEmulatorProfile is CustomEmulatorProfile customProfile)\r\n            {\r\n                currentEmuProfile = customProfile;\r\n            }\r\n            else if (action.SelectedEmulatorProfile is BuiltInEmulatorProfile builtinProfile)\r\n            {\r\n                currentEmuProfile = builtinProfile;\r\n            }\r\n            else\r\n            {\r\n                throw new Exception(\"Uknown play action configuration.\");\r\n            }\r\n\r\n            emulator = emulator.GetClone();\r\n            if (!emulator.InstallDir.IsNullOrEmpty())\r","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Controllers/GenericGameController.cs#L59-L95","documentation":"Thrown by GenericGameController.StartEmulator when database.Emulators[action.EmulatorId] returns null — i.e. no Emulator record exists with the given id. It is a bare Exception before any profile handling occurs.","triggerScenarios":"Launching a game whose play action references an EmulatorId that was deleted; id mismatch after a database migration/restore; action created against an emulator since removed; corrupted DB where the lookup returns null.","commonSituations":"User deleted or re-added an emulator so the stored EmulatorId is stale; imported library referencing a missing emulator; manual edit of game action EmulatorId.","solutions":["Validate database.Emulators.Contains(action.EmulatorId) before calling StartEmulator.","Re-select the emulator in the game's play action so the id is current.","If the emulator was removed, recreate it or pick a different one.","Repair/restore the game database if ids are inconsistent."],"exampleFix":"// before\ncontroller.StartEmulator(action, asyncExec, args);\n\n// after — validate emulator existence first\nif (!database.Emulators.Contains(action.EmulatorId))\n{\n    dialogs.ShowMessage(\"The emulator for this game no longer exists. Please re-select it.\");\n    return;\n}\ncontroller.StartEmulator(action, asyncExec, args);","handlingStrategy":"validation","validationCode":"if (!database.Emulators.Contains(action.EmulatorId)) throw new InvalidOperationException($\"Emulator {action.EmulatorId} not found\");","typeGuard":"static bool EmulatorExists(IGameDatabase db, Guid id) => db.Emulators.Contains(id) && db.Emulators[id] != null;","tryCatchPattern":"try { controller.StartEmulator(action, asyncExec, args); }\ncatch (Exception ex) when (database.Emulators[action.EmulatorId] == null) { dialogs.ShowMessage(\"Emulator no longer exists. Re-select it.\"); }","preventionTips":["Validate the EmulatorId still exists before launching.","Re-select the emulator when an emulator is deleted/re-added.","Repair the database if ids become inconsistent."],"tags":["emulator","database","validation","game-controller","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}