Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Handling with javascript errors  #13

@ilpaijin

Description

@ilpaijin

In case of a js error (on the page that phantomjs is trying to render) the converter returns the Exception but with success true and thus the page created.

I discovered the error within a page that uses "requestAnimationFrame" js object, and as far as I know Phantomsjs doesn't deal with it.

I'm working on handling the errors with phantomjs native handler like:

page.onError = function(msg, trace) {

    var msgStack = ['[ERROR]' + msg + " in " + page.url + "[/ERROR]"];

    if (trace && trace.length) 
    {
        msgStack.push('[TRACE]');
        trace.forEach(function(t) 
        {
            msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
        });
        msgStack.push('[/TRACE]');
    }

    returnConsoleMsg(msgStack.join('\n'), false);
};


function returnConsoleMsg(msg, result) 
{
    console.log(JSON.stringify({
        success: result,
        response: msg
    }));

    // Stop the script
    phantom.exit(0);
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions