Hide / change error message in the console

0

I try to get a file that does not exist on my site, like:

try {
    $.getScript('app/controllers/arquivo-errado.js', function(){});
} catch (e) {
    // caso de erro
}

The error is returned in the console:

  

GET URL ... app / controllers / wrong-file.js? _ = 1484154145345 404 (Not   Found)

I want to know how I can change or hide this error, for example, change it to a 'File does not exist' error, or without displaying the error.     

asked by anonymous 11.01.2017 / 18:06

1 answer

1

I do not think it's possible to delete or replace this browser's native 404 message. More:

1) You can add a default message by adding a callback .fail to the method:

$.getScript('app/controllers/arquivo-errado.js')
  .done(function( script, textStatus ) {
    console.log("Arquivo carregado com sucesso :)");
  })
  .fail(function( jqxhr, settings, exception ) {
    console.log("Não foi possível carregar o arquivo :(");
  });

2) or make a kind of proxy file that passes the js file to the client, but if it does not find it, it only renders a 200 code with no content. This way, the browser does not understand 404 and does not show the error. Just an idea.

    
11.01.2017 / 18:32