How can I catch errors such as unsuccessful loading of js css?

generally, it can be captured with try-catch or onerror, but if js,css,img, loading is not successful, how can I get the error?
Please advise!

Mar.11,2021

define error event listeners for window before loading

window.addEventListener('error', function(event) { ... })

https://developer.mozilla.org.

Menu