{"record":{"id":"ebe04cdb8923c5a1","repo":"cefsharp/CefSharp","slug":"expected-exception","errorCode":null,"errorMessage":"Expected Exception","messagePattern":"Expected Exception","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"info","filePath":"CefSharp.Example/JavascriptBinding/AsyncBoundObject.cs","lineNumber":257,"sourceCode":"        }\n\n        public async Task<string[]> AsyncDownloadFileAndSplitOnNewLines(string url)\n        {\n            var webClient = new WebClient();\n            var download = await webClient.DownloadStringTaskAsync(new Uri(url));\n\n            var lines = download.Split('\\n').Where(x => !string.IsNullOrEmpty(x.Trim())).ToArray();\n\n            return lines;\n        }\n\n        //We expect an exception here, so tell VS to ignore\n        [DebuggerHidden]\n        public async Task<string> AsyncThrowException()\n        {\n            await Task.Delay(2000);\n\n            throw new Exception(\"Expected Exception\");\n        }\n\n        public uint UIntAddModel(UIntAddModel model)\n        {\n            return model.ParamA + model.ParamB;\n        }\n\n        public uint UIntAdd(uint paramA, uint paramB)\n        {\n            return paramA + paramB;\n        }\n\n        public async Task<string> JavascriptOptionalCallbackEvalPromise(bool invokeCallback, string msg, IJavascriptCallback callback)\n        {\n            using (callback)\n            {\n                if (invokeCallback)\n                {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Example/JavascriptBinding/AsyncBoundObject.cs#L239-L275","documentation":"Thrown by AsyncBoundObject.AsyncThrowException() after a 2-second delay — example/test code that demonstrates how async C# methods propagate exceptions to JavaScript. Marked [DebuggerHidden] so Visual Studio does not break on it. Not a production error; it exists to exercise the async-exception bridge.","triggerScenarios":"Calling the bound asyncThrowException method from JavaScript in the example browser. Only present in CefSharp.Example.","commonSituations":"Running the example app's test page. Not encountered unless you reference AsyncBoundObject.","solutions":["Expected in example code — not a real defect.","If copied into your app, remove the method or wrap your JS caller in try/catch.","For your own async bound methods, ensure exceptions are intentional and documented."],"exampleFix":"// JavaScript\ntry { await asyncBoundObj.asyncThrowException(); }\ncatch (e) { console.log('Handled:', e.message); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In JavaScript\ntry { await asyncBoundObj.asyncThrowException(); }\ncatch (e) { console.log('Handled:', e.message); }","preventionTips":["Treat as expected demo behavior.","Remove from production if unwanted.","Wrap JS-bound async calls in try/catch."],"tags":["example-code","js-binding","async","intentional","exception-demo"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}