最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is phantom JS error code 1? - Stack Overflow

programmeradmin11浏览0评论

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.

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.

Share Improve this question asked Nov 15, 2013 at 15:05 metalaureatemetalaureate 7,74211 gold badges59 silver badges97 bronze badges 2
  • ` var phantomProc = childProcess.spawn(options.phantomPath, phantomArgs);` It's just a call to the phantomjs child process. – metalaureate Commented Nov 15, 2013 at 15:13
  • It could be Invalid Function. – Anto Jurković Commented Nov 15, 2013 at 15:26
Add a ment  | 

1 Answer 1

Reset to default 4

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 {
...
}
发布评论

评论列表(0)

  1. 暂无评论