Skip to content

How to get the line number of an error when executing code in the sandbox? #18

@IamSanjid

Description

@IamSanjid
const sandbox = new Sandbox();

const code = `function onStart() {
    console.log(some_undefined_var);
}
return { onStart: onStart };
`;

const exec = sandbox.compile(code);
const script_context = exec({}).run();

// here an error should occur...
script_context['onStart']();

So I would like to know at which line(maybe?) the error occurred while executing the code in the provided coding string, I think I can get the function name in a way but need some examples of how to approach this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions