{"record":{"id":"ce86271603e4a322","repo":"cefsharp/CefSharp","slug":"nested-exception-invalid","errorCode":null,"errorMessage":"Nested Exception Invalid","messagePattern":"Nested Exception Invalid","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"info","filePath":"CefSharp.Example/JavascriptBinding/ExceptionTestBoundObject.cs","lineNumber":30,"sourceCode":"    {\n        [DebuggerStepThrough]\n        private double DivisionByZero(int zero)\n        {\n            return 10 / zero;\n        }\n\n        [DebuggerStepThrough]\n        public double TriggerNestedExceptions()\n        {\n            try\n            {\n                try\n                {\n                    return DivisionByZero(0);\n                }\n                catch (Exception innerException)\n                {\n                    throw new InvalidOperationException(\"Nested Exception Invalid\", innerException);\n                }\n            }\n            catch (Exception e)\n            {\n                throw new OperationCanceledException(\"Nested Exception Canceled\", e);\n            }\n        }\n\n        [DebuggerStepThrough]\n        public int TriggerParameterException(int parameter)\n        {\n            return parameter;\n        }\n\n        public void TestCallbackException(IJavascriptCallback errorCallback, IJavascriptCallback errorCallbackResult)\n        {\n            const int taskDelay = 500;\n","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Example/JavascriptBinding/ExceptionTestBoundObject.cs#L12-L48","documentation":"Thrown as the inner exception in ExceptionTestBoundObject.TriggerNestedExceptions() — example code that deliberately creates a DivisionByZero, wraps it in an InvalidOperationException, which is then wrapped again in an OperationCanceledException. It tests how CefSharp serializes nested exception chains across the C#/JS boundary. Not a production error.","triggerScenarios":"Calling the bound TriggerNestedExceptions() method from JavaScript in the example browser. The inner division by zero is the original cause.","commonSituations":"Running the CefSharp.Example exception tests. Not present in production apps.","solutions":["Expected test/demo behavior — not a real defect.","Remove ExceptionTestBoundObject if you copied example code into your project.","In your own bound objects, avoid wrapping exceptions unnecessarily; let the original propagate."],"exampleFix":"// JavaScript\ntry { await boundObj.triggerNestedExceptions(); }\ncatch (e) {\n  console.log(e); // contains inner chain for inspection\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In JavaScript\ntry { await boundObj.triggerNestedExceptions(); }\ncatch (e) { console.log('Inner chain:', e); }","preventionTips":["Recognize as intentional nested-exception demo.","Do not copy ExceptionTestBoundObject into production.","Design your bound objects to throw single, typed exceptions."],"tags":["example-code","js-binding","nested-exception","intentional"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}