diff --git a/CefSharp.Test/JavascriptBinding/JavaScriptObjectRepositoryFacts.cs b/CefSharp.Test/JavascriptBinding/JavaScriptObjectRepositoryFacts.cs index 6695ebb36c..03c0b9981a 100644 --- a/CefSharp.Test/JavascriptBinding/JavaScriptObjectRepositoryFacts.cs +++ b/CefSharp.Test/JavascriptBinding/JavaScriptObjectRepositoryFacts.cs @@ -49,6 +49,16 @@ public void CanRegisterJavascriptObjectBindWhenNamespaceIsNull() Assert.Equal("ok", result.ReturnValue.ToString()); } + [Fact] + public void ShouldReturnErrorMessageForObjectInvalidId() + { + IJavascriptObjectRepositoryInternal javascriptObjectRepository = new JavascriptObjectRepository(); + + var result = javascriptObjectRepository.TryCallMethod(100, "getExampleString", new object[0]); + Assert.False(result.Success); + Assert.StartsWith("Object Not Found Matching Id", result.Exception); + } + #if !NETCOREAPP [Fact] public void CanRegisterJavascriptObjectPropertyBindWhenNamespaceIsNull() diff --git a/CefSharp/Internals/JavascriptObjectRepository.cs b/CefSharp/Internals/JavascriptObjectRepository.cs index b9aa11ec9b..e8f79fdd6d 100644 --- a/CefSharp/Internals/JavascriptObjectRepository.cs +++ b/CefSharp/Internals/JavascriptObjectRepository.cs @@ -293,7 +293,9 @@ protected virtual TryCallMethodResult TryCallMethod(long objectId, string name, if (!objects.TryGetValue(objectId, out obj)) { - return new TryCallMethodResult(false, result, "Object Not Found Matching Id:" + objectId); + var paramCount = parameters == null ? 0 : parameters.Length; + + return new TryCallMethodResult(false, result, $"Object Not Found Matching Id:{objectId}, MethodName:{name}, ParamCount:{paramCount}"); } var method = obj.Methods.FirstOrDefault(p => p.JavascriptName == name);