pub fn check_script_syntax<S: Into<JSString>, U: Into<JSString>>(
ctx: &JSContext,
script: S,
source_url: U,
starting_line_number: i32,
) -> Result<(), JSException>Expand description
Checks for syntax errors in a string of JavaScript.
ctx: The execution context to use.script: A string containing the script to check for syntax errors.source_url: An optional string containing a URL for the script’s source file. This is only used when reporting exceptions. PassNoneif you do not care to include source file information in exceptions.starting_line_number: An integer value specifying the script’s starting line number in the file located atsource_url. This is only used when reporting exceptions. The value is one-based, so the first line is line1and invalid values are clamped to1.
Returns Ok if the script is syntactically correct, otherwise
returns an exception.
use javascriptcore::*;
let ctx = JSContext::default();
let r = check_script_syntax(&ctx, "alert('abc');", "test.js", 1);
assert!(r.is_ok());