I am loading an invalid source into videojs player instance like this:
player.src({
src: 'http://example.com/invalid',
type: 'audio/mp4',
});
Then I try to catch the occurring error as follows:
player.on('error', () => {
console.log(player.error); //Gives MEDIA_ERR_SRC_NOT_SUPPORTED error
})
which gives me the error thrown internally by videojs, but not the error that caused it. In my application, I am consuming an API that throws specific error code if you are trying to load a source that you are not supposed to. How could I catch such an error.
I would like to catch the first error in the screenshot below: