javascript - PhantomJS - Handling Network Error -


when run phantomjs script in debug mode, see error : [debug] network - resource request error: 5 ( "operation canceled" ).

when run script 1000 times, i've error 1 or 2 times. want catch without running script in debug mode don't know how !

i try several error handlers :

phantom.onerror = function(msg, trace) {   console.log("phantomjs onerror\n"); };  page.onerror = function(msg, trace) {   console.log("phantomjs onerror\n"); };  page.onresourceerror = function(resourceerror) {   console.log("phantomjs onresourceerror\n"); };  page.onresourcetimeout = function(req) {   console.error('phantomjs onresourcetimeout\n'); };  page.onloadfinished = function(status) {   if (status != 'success') {     console.error('phantomjs onloadfinished error\n');   } }; 

do have idea me ? how can catch error ? use phantomjs 1.9.7 x64 on unix.

thanks,

this question may old had same trouble today , found workaround:

var numberofrequests = 0; page.onresourcereceived = function(response) {     if (numberofrequests === 0) {         // if status of first resource null there network error         if (response.status === null) {             console.log('[error] loading page failed: network error');             phantom.exit();         }     }      numberofrequests++; }; 

tested phantomjs 2.1. hope may else.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -