简体   繁体   English

什么是幻影JS错误代码1?

[英]What is phantom JS error code 1?

I get error code #1 when rendering some web pages but not others in phantomJS. 渲染某些网页但在phantomJS中渲染其他网页时出现错误代码#1。 The block is in a 3rd party module that calls phantomJS to take the screenshot. 该块位于第3方模块中,该模块调用phantomJS来截取屏幕截图。

  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? 什么是错误代码1? I can't find any reference to phantomJS error codes online. 我在网上找不到对phantomJS错误代码的任何引用。

code is the return code the script execution. code是脚本执行的返回码。

This is generally manage inside the client script, by calling phantom.exit(code) . 通常,这是在客户端脚本中通过调用phantom.exit(code) The convention on phantomjs examples, is to use 1 for invalid parameters. phantomjs示例的约定是对无效参数使用1

For example, check the loadspeed.js 例如,检查loadspeed.js

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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