title: jQuery "Uncaught" on ajax call inside try... catch
body: <p>I have a Advanced Custom Field on WordPress edit post admin page that requires some validation. This validation is done via ajax (I am pretty sure though that acf and WordPress are irrelevant to this question).</p>
  
  <p>Unfortunately I get the following error in the console: <code>Uncaught Not a valid flickr.com url</code> (line 16) for the following code:</p>
  
  <pre><code>jQuery(document).ready(function($) {
      var initialVal = $('#acf-field_560aabcf8dbef').val();
      $('#acf-field_560aabcf8dbef').on('paste', function(e) {
          var pasteData = e.originalEvent.clipboardData.getData('text');
          if (initialVal !== pasteData) {
              try {
                  $.get(ajaxurl, 
                      {
                          'action': 'ai_check_url_id',
                          'idOrUrl': pasteData
                      },
                      function(response) {
                          response = $.parseJSON(response);
                          if (response.error) {
                              throw response.error.msg;
                          }
  
                          console.log(response);
                      }
                  );
              } catch (e) {
                  console.error(e);
              }
          };
      });
  });
  </code></pre>
  
  <p>The php function</p>
  
  <pre><code>&lt;?php
      function ajaxIdOrUrl() 
      {
          try {
              echo $this-&gt;idOrUrl($_GET['idOrUrl']);
          } catch (\Exception $e) {
              echo json_encode([
                  'error' =&gt; [
                      'msg' =&gt; $e-&gt;getMessage(),
                      'code' =&gt; $e-&gt;getCode(),
                  ],
              ]);
          }
  
          wp_die();
      }
  </code></pre>
  
  <p>What it does is:</p>
  
  <ul>
  <li>the <code>ajaxurl</code> is defined on the page</li>
  <li>on a paste event check if the value has changed</li>
  <li>if it has, make a <code>get</code> request and send the changed data along</li>
  <li>the answer is either an ID or an error array</li>
  </ul>
  
  <p>Can anybody point me in the right direction why this shows up as being uncaught (the code works fine when there is no error)?</p>