最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin11PV0评论

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 {
...
}
Post a comment

comment list (0)

  1. No comments so far