Stinkstudios / sono

A simple yet powerful JavaScript library for working with Web Audio
http://stinkstudios.github.io/sono/
MIT License
170 stars 15 forks source link

onError callback doesn't get fired #21

Closed ameliemaia closed 7 years ago

ameliemaia commented 7 years ago

Hi Ian,

Whilst writing a test for loading I came across a bug where onError never gets fired if the asset url is wrong.

const sound = sono.load({
  src: [
    '/assets/audio/dnb-loop.m3',
  ],
  onComplete: () => {
   console.log('loaded');
  },
  onError: () => {
    console.log('error');
  }
});

However if I then add this after the code above both error events get fired:

sound.on('error', () => {
  console.log('error2');
})

I looked at https://github.com/Stinkstudios/sono/blob/master/test/loader.spec.js and noticed you didn't have a test for assets failing to load.

Let me know if you need anymore info!

ianmcgregor commented 7 years ago

Hi Amelie. Thanks for finding this. Error handling isn't the best at the moment in sono -- I think, as you mention, the first step is getting some unit tests in to see where it needs some love