assaf / node-passbook

iOS Passbook for the Node hacker
MIT License
280 stars 73 forks source link

Error handling in doneWithImages() of pass.js #25

Open yagamy4680 opened 9 years ago

yagamy4680 commented 9 years ago

I met an error that passbook module doesn't throw out error when wwdr.pem is not stored at the key directory:

Error opening certificate file /workspaces/pass_book_server/work/data/developers/E5WU58LN/keys/wwdr.pem
139861670852256:error:02001002:system library:fopen:No such file or directory:bss_file.c:169:fopen('/workspaces/pass_book_server/work/data/developers/E5WU58LN/keys/wwdr.pem','r')
139861670852256:error:2006D080:BIO routines:BIO_new_file:no such file:bss_file.c:172:

After debugging, I figure out that doneWithImages() doesn't handle the error from callback of self.signZip() properly, so I modify doneWithImages() as below to fix this bug.

  function doneWithImages() {
    if (lastError) {
      zip.close();
      self.emit("error", lastError);
    } else {
      self.signZip(zip, manifest, function(error) {
        // add codes: BEGIN
        if (error) {
          self.emit("error", error);          
        }
        // add codes: END
        zip.close();
        zip.on("end", function() {
          self.emit("end");
        });
        zip.on("error", function(error) {
          self.emit("error", error);
        });
      });
    }
  }

I will try to fork your repository, add test, and send pull request back to you for this issue later.