title: Catching invalid source error using videojs
body: <p>I am loading an invalid source into videojs player instance like this:</p>
  
  <pre class="lang-js prettyprint-override"><code>player.src({
      src: 'http://example.com/invalid',
      type: 'audio/mp4',
  });
  </code></pre>
  
  <p>Then I try to catch the occurring error as follows:</p>
  
  <pre class="lang-js prettyprint-override"><code>player.on('error', () =&gt; {
      console.log(player.error); //Gives MEDIA_ERR_SRC_NOT_SUPPORTED error
  })
  </code></pre>
  
  <p>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.</p>
  
  <p>I would like to catch the first error in the screenshot below:
  <a href="https://i.stack.imgur.com/oBt7Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oBt7Q.png" alt="enter image description here"></a></p>