{"record":{"id":"7bfd0b2b304fc504","repo":"JosefNemec/Playnite","slug":"non-empty-process-name-must-be-specified","errorCode":null,"errorMessage":"Non empty process name must be specified.","messagePattern":"Non empty process name must be specified\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Common/ProcessMonitor.cs","lineNumber":176,"sourceCode":"                {\r\n                    return process.Id;\r\n                }\r\n            }\r\n\r\n            return 0;\r\n        }\r\n    }\r\n}\r\n\r\npublic class MonitorProcessName\r\n{\r\n    public string ProcessName { get; }\r\n\r\n    public MonitorProcessName(string processName)\r\n    {\r\n        if (processName.IsNullOrWhiteSpace())\r\n        {\r\n            throw new Exception(\"Non empty process name must be specified.\");\r\n        }\r\n\r\n        ProcessName = processName;\r\n    }\r\n\r\n    public int IsProcessRunning()\r\n    {\r\n        foreach (var process in Process.GetProcesses().Where(a => a.SessionId != 0))\r\n        {\r\n            using (process)\r\n            {\r\n                if (process.ProcessName == ProcessName)\r\n                {\r\n                    return process.Id;\r\n                }\r\n            }\r\n        }\r\n\r","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Common/ProcessMonitor.cs#L158-L194","documentation":"Thrown by the MonitorProcessName constructor (via IsNullOrWhiteSpace check) when processName is null, empty, or whitespace. NOTE: it throws the base Exception type rather than ArgumentNullException, and the message is the only signal. The class is used to watch whether a named process is running for game-tracking purposes.","triggerScenarios":"Constructing new MonitorProcessName(name) where name is null/empty/whitespace; passing a value loaded from a game's action config that was never populated; a binding/designer that instantiates with a default empty string.","commonSituations":"A game action with an empty tracking process name (manual edit or imported library missing the field); scripting/plugin code building a monitor from an unvalidated property.","solutions":["Validate the process name is non-whitespace before constructing MonitorProcessName.","Fix the game/emulator action configuration so the tracking process name is set.","Guard upstream callers against null action.ProcessName."],"exampleFix":"// before\nvar mon = new MonitorProcessName(action.ProcessName);\n\n// after — guard empty names\nif (action.ProcessName.IsNullOrWhiteSpace())\n{\n    logger.Warn(\"Skipping monitor: empty process name\");\n    return;\n}\nvar mon = new MonitorProcessName(action.ProcessName);","handlingStrategy":"validation","validationCode":"if (processName.IsNullOrWhiteSpace()) throw new ArgumentException(\"process name required\");","typeGuard":"static bool IsValidProcessName(string s) => !s.IsNullOrWhiteSpace();","tryCatchPattern":"try { return new MonitorProcessName(name); }\ncatch (Exception ex) when (name.IsNullOrWhiteSpace()) { logger.Warn(\"empty process name\"); return null; }","preventionTips":["Validate the process name upstream where the action is configured.","Refuse to create monitors for actions with empty tracking names.","Surface a config error to the user instead of letting the ctor throw."],"tags":["process","validation","game-tracking","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}