Right now, chrome --exec-script "some invalid script" ... returns null, rather than printing an informative message to the user about what what's happened. However, the console in the problematic window shows the error just fine. Try wrapping the user's script into a try-catch shell inside chrome_agent_client.js` before sending it for execution to the tab, and returning the caught exception.
Also, to return a result, the script currently must end in a statement that evaluates to that result, e.g. document.querySelector('...'): using return with it (return document.querySelector('...')) creates an error. Using return is rather intuitive, so we should find a way to allow it, e.g. wrap the user's script into a (function() { <script> })();.
Right now,
chrome --exec-script "some invalid script" ...
returns null, rather than printing an informative message to the user about what what's happened. However, the console in the problematic window shows the error just fine. Try wrapping the user's script into atry-catch
shell inside chrome_agent_client.js` before sending it for execution to the tab, and returning the caught exception.Also, to return a result, the script currently must end in a statement that evaluates to that result, e.g.
document.querySelector('...')
: usingreturn
with it (return document.querySelector('...')
) creates an error. Usingreturn
is rather intuitive, so we should find a way to allow it, e.g. wrap the user's script into a(function() { <script> })();
.