How to hide default browser error messages?

Asked

Viewed 68 times

2

I would like it to appear on the console, only the message placed on the Reject and hide that default GET error from the browser.

    function loadScript(src) {
        return new Promise((resolve, reject) => {
            let script = document.createElement('script')
            script.src = src
            script.onload = resolve(script)
            script.onerror = reject(console.log(new Error('Ocorreu algum erro.')))
            document.head.append(script)
        })
    }
    loadScript('msf.js')

The mistake:

Error: Ocorreu algum erro.
    at promise_version.html:18
    at new Promise (<anonymous>)
    at loadScript (promise_version.html:14)
    at promise_version.html:23

GET file:///home/art/Art/promise_assync_await/msf.js net::ERR_FILE_NOT_FOUND
(anonymous) @ promise_version.html:19
loadScript @ promise_version.html:14
(anonymous) @ promise_version.html:23

1 answer

0


  • 1

    While this link may answer the question, it is best to include the essential parts of the answer here and provide the link for reference. Replies per link only can be invalidated if the page with the link is changed. - Of Revision

  • 1

    Thanks for ringing @Luizaugusto! I improved my answer :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.