mirror of
https://github.com/danbulant/ester_os
synced 2026-05-19 04:08:44 +00:00
Remap console to catch reload errors
This commit is contained in:
parent
2b73d88428
commit
3324aedbf6
1 changed files with 20 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Reference in a new issue