{"record":{"id":"34933278abca1035","repo":"HMCL-dev/HMCL","slug":"id","errorCode":null,"errorMessage":"${id}","messagePattern":"\\$\\{id\\}","errorType":"exception","errorClass":"NoSuchGameInstanceException","httpStatus":null,"severity":"error","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/game/DefaultGameRepositorySnapshot.java","lineNumber":106,"sourceCode":"    /// Returns the instance with the given id.\n    ///\n    /// @param id the instance id\n    /// @return the instance, or `null` when absent\n    public @Nullable DefaultGameInstance get(GameInstanceID id) {\n        return instances.get(id);\n    }\n\n    /// Returns the registered instance with the given id.\n    ///\n    /// @param id the instance id\n    /// @return the registered instance\n    /// @throws NoSuchGameInstanceException if the instance is absent\n    public DefaultGameInstance getRegistered(GameInstanceID id) throws NoSuchGameInstanceException {\n        DefaultGameInstance instance = instances.get(id);\n        if (instance != null) {\n            return instance;\n        }\n        throw new NoSuchGameInstanceException(id);\n    }\n\n    /// {@inheritDoc}\n    @Override\n    public boolean hasInstance(GameInstanceID instanceId) {\n        return instances.containsKey(instanceId);\n    }\n\n    /// {@inheritDoc}\n    @Override\n    public DefaultGameInstance getInstance(GameInstanceID instanceId) throws NoSuchGameInstanceException {\n        return getRegistered(instanceId);\n    }\n\n    /// {@inheritDoc}\n    @Override\n    public @Nullable DefaultGameInstance findInstance(GameInstanceID instanceId) {\n        return instances.get(instanceId);","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/game/DefaultGameRepositorySnapshot.java#L88-L124","documentation":"DefaultGameRepositorySnapshot.getRegistered looks up an instance by GameInstanceID in its registry and throws NoSuchGameInstanceException when the id is not registered. It is the strict accessor behind getInstance; use hasInstance first if absence is expected. The exception message is the instance id string.","triggerScenarios":"Calling getInstance/getRegistered with an id that was never added to the repository, or one that was removed; passing an id parsed from stale config or an old snapshot.","commonSituations":"Typo or wrong case in the instance id in settings; referencing an instance after the user deleted it; using a GameInstanceID from a different repository instance; deserialized ids from outdated saves.","solutions":["Call hasInstance(id) (or list registered ids) before getRegistered to confirm existence","Re-scan/reload the repository so newly added instances are registered","Correct the instance id in the calling configuration or code","Create the missing instance if it was expected to exist"],"exampleFix":"// before\nDefaultGameInstance inst = snapshot.getRegistered(id); // throws if absent\n// after\nif (snapshot.hasInstance(id)) {\n    DefaultGameInstance inst = snapshot.getRegistered(id);\n} else {\n    inst = createOrSkip(id);\n}","handlingStrategy":"type-guard","validationCode":"if (!snapshot.hasInstance(id)) { /* handle absence: create, skip, or report */ }","typeGuard":"Optional<DefaultGameInstance> findRegistered(DefaultGameRepositorySnapshot s, GameInstanceID id) {\n    return s.hasInstance(id) ? Optional.of(s.getRegistered(id)) : Optional.empty();\n}","tryCatchPattern":"try { inst = snapshot.getRegistered(id); }\ncatch (NoSuchGameInstanceException e) { inst = null; LOG.warning(\"Unknown instance: \" + e.getMessage()); }","preventionTips":["Check hasInstance before strict lookups","Keep GameInstanceIDs sourced from the repository's own listing, not stale config","Refresh the snapshot after external instance changes"],"tags":["instance","lookup","not-found"],"backgroundTag":"record-not-found","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}