[][src]Function ul::jsc::check_script_syntax

pub fn check_script_syntax<S: Into<JSString>, U: Into<JSString>>(
    ctx: &JSContext,
    script: S,
    source_url: U,
    starting_line_number: i32
) -> Result<(), JSException>

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. Pass None if 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 at source_url. This is only used when reporting exceptions. The value is one-based, so the first line is line 1 and invalid values are clamped to 1.

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());