Unhandled Rejection in spark.min.js

I’m using Javascript in my browser to control my Photon. I had a weird situation where a line of Javascript just went nowhere; I step over the line in Firebug and control never comes back. I tried it in Safari and the tools there warn of a possible unhandled rejection in spark.min.js. I’m not a Javascript guru - perhaps there is an odd condition in spark.min.js?

Here’s a bit of my pseudo code…

var devicesPr = spark.listDevices();
devicesPr.then(devicesPrTrue, devicesPrFalse);

devicesPrTrue(devices) calls

var devList = spark.devices;

I then iterate through each entry in the devList and use .id and .name to construct a drop down list for my user to choose.

At one point I do

var something = entry.id

and Safari reports this:

Potentially unhandled rejection [1] devicesPrTrue...

at line 7976 in spark.min.js That line is

console.error(e)

Once I post this I’ll add a screen shot of the Safari debugger.

This might be completely my problem, and I’ll take any advice that’s offered.

Jim

It would help to see the actual code – there may be a subtle error that we can help you find. And even better if you can replicate the problem with some code that is as minimal as possible.

Any advice on what the error means? Shouldn’t the spark.min.js library always return control to my javascript?
Jim

Why spark.devices? Shouldn't that just be

var devList = devices;

(which would be unnecessary, since it would just be a reference alias...)

Thanks for the suggestions. I ran JSLint on my code and it suggested changing some of my code from this (which I like for readability)

I had something like this inside a closure in a devList.forEach loop…

output = 'Some stuff'
   + entry.id
   + 'yet more stuff';

into this structure…

output = 'Some stuff' +
    entry.id +
    'yet more stuff';

And when I did that the issue disappeared. Apparently JS parsers will insert semi-colons places they think they belong. Perhaps that was the source of the issue.

Have I said how much I hate JavaScript?

Jim