Handling Global JavaScript Errors

preview_player
Показать описание
When working with webpages Errors will happen. It is just a fact of life. There are a few ways that you can handle and capture those errors.

try{ } catch(err) { }

Keep in mind that errors in external scripts can have their details hidden from you unless you use the crossorigin="anonymous" attribute in your script tag.

Рекомендации по теме
Комментарии
Автор

Your voice is nice and clear I really enjoy your tutorial, thanks!!!

estebanpetliuk
Автор

broo!!! you interesting m so much and exlpaining good that i dont even get tired for 1 sec!!! plz keep uploading i rlly love your content!!! your explanations soooo goood!!! now i feel so much better cuz of u
u explain so much info in short amount of time and explaining soooo well!! fluently

CT
Автор

Well explained sir. This helped me understand window error listening.

MichaelSalo
Автор

Your voice is as great as your lesson!~ 😄

mister.z
Автор

Hello Steve, thanks for such a good explanation. I have a question, do you know if that crossorigin attribute applies to jquery or mootools script invokes? I mean, with that I'm gonna be able to catch any error triggered by them, am I right?

JesusSanchez-edwf
Автор

What's alternative of error event in nodejs?
unhandledrejection and unhandledRejection are two different events and have different standards? I learned, unhandledrejection is a html standard event.

damo
Автор

hi
function errorEventHandler(event, source, lineno, colno, error) {
console.log(event);
console.log(error);
}

const images =
for (let index = 0; index < images.length; index++) {
images[index].addEventListener('error', errorEventHandler);
}
this is a code of index.js file referenced in my index.html page
The later contains images that may lead to error ( like an image with jxl file type which is not upported in firefox)
The things is the error parameter returns undefined
Which is not I was assuming after reading this in MDN
All event handler attributes accept a string. The string will be used to synthesize a JavaScript function like function name(/args/) {body}, where name is the attribute's name, and body is the attribute's value. The handler receives the same parameters as its JavaScript event handler counterpart — most handlers receive only one event parameter, while onerror receives five: event, source, lineno, colno, error. This means you can, in general, use the event variable within the attribute.
from this MDN page

codiaji
visit shbcf.ru