layout |
---|
default |
' + stack + '
=== window.onerror args ===
' + onerror + '
=== window.onerror error arg ===
' + errObj; return true; }; fn(); window.onerror = originalOnError; }); } </script>
Errors which are not caught in a try/catch will bubble up the window's error handler. This is your last chance to log the error for reporting. Some browsers report slightly different information, or will not report any information at all. This page will interactively explain these intricacies, and acts as a "test runner".
This function is inlined into this page, so it is served from the same domain. Error reporting should be correct.
function inlineFn () {
throw new Error('inlineFn-error');
}
Run inlineFn()
Browser | window.onerror msg |
window.onerror url |
window.onerror line:col |
error msg |
error url |
error line:col |
---|---|---|---|---|---|---|
Chrome | Uncaught Error: inline-error | https://safari-cors-errors.framba.ch/ | 79:3 | inline-error | ||
Firefox | Error: inline-error | https://safari-cors-errors.framba.ch/ | 79:9 | inline-error | ||
Safari | Error: inline-error | https://safari-cors-errors.framba.ch/ | 79:34 | inline-error | https://safari-cors-errors.framba.ch/ | 79:18 |
An inline script generates a new function from a string and executes it.
function newFn () {
var fn = new Function("throw new Error('newFn-error')");
fn();
}
Run newFn()
| Browser | window.onerror
msg | window.onerror
url | window.onerror
line:col | error
msg | error
url
line:col |
|:------|:------|:------|:------|:------|:------|:------|
| Chrome | Uncaught Error: newFn-error | https://safari-cors-errors.framba.ch/ | 3:1 | newFn-error | |
| Firefox | Error: newFn-error | https://safari-cors-errors.framba.ch/ line 143 > Function | 3:7 | newFn-error | |
| Safari | Error: newFn-error | | 2:16 | newFn-error | | 2:16 |
This function is defined on a different domain, with crossorigin="anonymous" and CORS enabled. Safari shows "Script Error.", ostensibly for secrity reasons.
// Defined externally
function externalFn() {
throw new Error("externalFn-error");
}
Run externalFn()
| Browser | window.onerror
msg | window.onerror
url | window.onerror
line:col | error
msg | error
url
line:col |
|:------|:------|:------|:------|:------|:------|:------|
| Chrome | Uncaught Error: external-cors-error | https://safari-cors-external.framba.ch/external-fn.js | 2:9 | external-cors-error | |
| Firefox | Error: external-cors-error | https://safari-cors-external.framba.ch/external-fn.js | 2:9 | external-cors-error | |
| Safari | Script error. | | | | | |
This function is defined on a different domain, with crossorigin="anonymous" and CORS enabled. On our domain, we try/catch the function call, but immediately rethrow the error.
// Defined externally
function externalFn() {
throw new Error("external-cors-error");
}
// Defined inline
function rethrowExternalFn() {
try {
externalFn();
} catch (e) {
throw e;
}
}
Run rethrowExternalFn()
| Browser | window.onerror
msg | window.onerror
url | window.onerror
line:col | error
msg | error
url
line:col |
|:------|:------|:------|:------|:------|:------|:------|
| Chrome | Uncaught Error: external-cors-error | https://safari-cors-errors.framba.ch/ | 283:5 | external-cors-error | |
| Firefox | Error: external-cors-error | https://safari-cors-external.framba.ch/external-fn.js | 2:9 | external-cors-error | |
| Safari | Error: external-cors-error | https://safari-cors-errors.framba.ch/ | 283:12 | external-cors-error | https://safari-cors-external.framba.ch/external-fn.js | 2:18 |