Remap console to catch reload errors

This commit is contained in:
danbulant 2020-02-16 10:24:59 +01:00
parent 2b73d88428
commit 3324aedbf6

View file

@ -1,5 +1,25 @@
import boot from './managers/boot';
//Remap console (so console.error is catched by error handler)
var console = (function (oldCons) {
return {
...oldCons,
error: function (text:any) {
if(text instanceof Error){
throw text;
} else {
throw Error(text);
}
}
};
}(window.console));
//Make console writeable
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
(window as Writeable<Window>).console = console;
//Handle errors
window.onerror = (msg, url, line, col, error)=>{
var e = document.createElement("div");