Evgeny Evgeny - 5 months ago 47
Javascript Question

iMacros: Doesn't work try catch syntax in javascript

I write some iMacros script using js in firefox.
But i can't use try catch syntax.


try {
throw new Error("NotImplementedError message");
} catch (ex1) {
alert("ex1 instanceof Error = " + (ex1 instanceof Error));
alert("ex1.name = " + ex1.name);
alert("ex1.message = " + ex1.message);
}

TypeError: ex1 is undefined, line 5


screenshot

Answer

I've sent a report. They've approved it. But I don't know then they'll resolve it.

So I wrote temporary fix:

    let Exception = {
        error: undefined,
        throw: function(error){
            this.error = error;
            throw error;
        },
    };

Using:

    try {
        Exception.throw(new Error('some text'));
    } catch(e) {
        e = Exception.error;
    //...
    }