1
Vote

Exception is thrown when Pictures folder is empty

description

If the Pictures folder of the current user doesn't contain any images when the sample is run, the following exception is thrown:
Exception is about to be caught by JavaScript library code at line 38, column 13 in ms-appx://microsoft.sdksamples.hilo.js/Hilo/Picture.js

0x800a138f - JavaScript runtime error: Unable to get property 'name' of undefined or null reference

If there is a handler for this exception, the program may be safely continued.
This exception is being thrown inside the PictureConstructor function (of the Picture.js file) due to the file argument being undefined.

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

comments

fmartinez wrote May 3, 2013 at 6:25 PM

Hi,

I've found that the problem was related to the processNextFile function in the _createViewModels function from the imageQueryBuilder.js, which was trying to call the Hilo.Picture function on an invalid index of the array from the Pictures folder. In order to workaround this issue you can change the code from the processNextFile function for the following one:
function processNextFile() {
   if (index < 0) {
      complete(results);
   } else if (!proceed) {
      error("Cancel");
   } else {
      var file = files[index];
      results[index] = new Hilo.Picture(file);
      index--;
      setImmediate(processNextFile);
   }
}

Regards,

Federico Martinez
http://blogs.southworks.net/fmartinez