{"record":{"id":"396279d9cbfad397","repo":"JosefNemec/Playnite","slug":"unsupported-url-format","errorCode":null,"errorMessage":"Unsupported URL format.","messagePattern":"Unsupported URL format\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Commands/GlobalCommands.cs","lineNumber":76,"sourceCode":"        });\r\n\r\n        public static void NavigateUrl(object url)\r\n        {\r\n            if (url is string stringUrl)\r\n            {\r\n                NavigateUrl(stringUrl);\r\n            }\r\n            else if (url is Link linkUrl)\r\n            {\r\n                NavigateUrl(linkUrl.Url);\r\n            }\r\n            else if (url is Uri uriUrl)\r\n            {\r\n                NavigateUrl(uriUrl.OriginalString);\r\n            }\r\n            else\r\n            {\r\n                throw new Exception(\"Unsupported URL format.\");\r\n            }\r\n        }\r\n\r\n        public static void NavigateUrl(string url)\r\n        {\r\n            if (url.IsNullOrEmpty())\r\n            {\r\n                throw new Exception(\"No URL was given.\");\r\n            }\r\n\r\n            if (url.StartsWith(\"{DocsRootUrl}\", StringComparison.OrdinalIgnoreCase))\r\n            {\r\n                url = Url.Combine(PlayniteEnvironment.DocsRootUrl, url.Replace(\"{DocsRootUrl}\", \"\"));\r\n            }\r\n\r\n            url = url.Replace(\"{AppBranch}\", PlayniteEnvironment.AppBranch);\r\n            if (!Regex.IsMatch(url, @\"^.*:\\/\\/\"))\r\n            {\r","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Commands/GlobalCommands.cs#L58-L94","documentation":"Thrown by the URL command dispatcher when the `url` argument is not one of the supported types (string, Link, or Uri). The method switches on the runtime type of an object parameter; anything else falls through to the throw, signaling an unsupported input shape rather than a bad value.","triggerScenarios":"Calling the NavigateUrl(object url) overload with a value whose runtime type is not string, Link, or Uri — e.g. a raw Guid, int, custom model object, or null.","commonSituations":"A command binding passes a model object or id instead of its Url property; a generic command handler forwards arbitrary objects; null passed where a typed value was expected.","solutions":["Pass the correct type: extract .Url from a Link, call .ToString()/.OriginalString on a Uri, or a plain string.","Type-check the argument before dispatch and convert it to string/Link/Uri.","Narrow the command parameter type at the binding source so unsupported types never reach the dispatcher."],"exampleFix":"// before\nCommands.NavigateUrl(someModel);\n\n// after\nCommands.NavigateUrl(someModel.WebUrl);  // pass a string","handlingStrategy":"type-guard","validationCode":"switch (url)\n{\n    case string s: Commands.NavigateUrl(s); break;\n    case Link l: Commands.NavigateUrl(l.Url); break;\n    case Uri u: Commands.NavigateUrl(u.OriginalString); break;\n    default: logger.Warn($\"Unsupported url type: {url?.GetType()}\"); break;\n}","typeGuard":"static bool IsSupportedUrl(object url) => url is string || url is Link || url is Uri;","tryCatchPattern":"try { Commands.NavigateUrl(url); }\ncatch (Exception e) when (e.Message.Contains(\"Unsupported URL format\"))\n{ logger.Warn(e, $\"Bad url type: {url?.GetType()}\"); }","preventionTips":["Pass only string, Link, or Uri to the url dispatcher.","Narrow command-parameter types at the binding source.","Extract .Url from models before forwarding to NavigateUrl."],"tags":["url","type-dispatch","commands","playnite"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}