PhantomJS - onResourceError()



This callback is called when the webpage is not able to upload the file. The arguments to it is the error object.

The error object contains −

  • Id − The number of the request.

  • URL − The URL called.

  • ErrorCode − error code.

  • ErrorString − error details

Syntax

Its syntax is as follows −

wpage.onResourceError = function(resourceError) {}

Example

The following example shows the use of onResourceError() method.

var wpage = require('webpage').create(); 
wpage.onResourceError = function(error) { 
   console.log(JSON.stringify(error));   
} 
wpage.open('http://localhost/tasks/prompt1.html', function(status) {  
});

The above program generates the following output.

{"errorCode":203,"errorString":"Error downloading http://localhost/tasks/prompt
.html - server replied: Not Found","id":1,"status":404,"statusText":"Not Found",
"url":"http://localhost/tasks/prompt1.html"}
phantomjs_webpage_module_events_callbacks.htm
Advertisements