I am creating and attaching a script tag dynamically in a script. Along with that I am adding an onerror handler.
However, when the script fails to load I don't get any details as to why it failed. I would expect some details about script not available (a 404) , or timeout or anything else useful. Any way to get that information ?
Note that I need to get the data programmatically so I can send it to Sentry. It’s for debugging user errors and I may not have access to their browsers and dev tools
const newScriptElement = document.createElement('script');
newScriptElement.src = url;
newScriptElement.type = 'text/javascript';
newScriptElement.async = true;
newScriptElement.id = scriptId;
newScriptElement.onerror = (ev) => {
console.log(ev.message); // <-- The message property doesn't exist. But also no other message like property
};
document.head.appendChild(newScriptElement);