简体   繁体   中英

What is phantom JS error code 1?

I get error code #1 when rendering some web pages but not others in phantomJS. The block is in a 3rd party module that calls phantomJS to take the screenshot.

  if (path) {
    phantomProc.on('exit', function(code) {
      if (!calledCallback) {
        calledCallback = true;

        // No need to run the timeout anymore.
        clearTimeout(timeoutID);
        cb(code
          ? new Error('PhantomJS exited with return value ' + code)
          : null);
      }
    });

What is error code 1? I can't find any reference to phantomJS error codes online.

code is the return code the script execution.

This is generally manage inside the client script, by calling phantom.exit(code) . The convention on phantomjs examples, is to use 1 for invalid parameters.

For example, check the loadspeed.js

if (system.args.length === 1) {
    console.log('Usage: loadspeed.js <some URL>');
    phantom.exit(1);
} else {
...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM