feat(fe/app): add global error listener
This commit is contained in:
parent
9d7a681552
commit
4fb6dd79a3
1 changed files with 15 additions and 7 deletions
|
@ -2,13 +2,21 @@ import * as React from "react";
|
|||
import * as ReactDOM from "react-dom";
|
||||
|
||||
import { StateMgr } from "./components/state_mgr";
|
||||
import { ErrorLogger } from "./common/log_error";
|
||||
import { errCorsScript } from "./common/errors";
|
||||
|
||||
// import "./theme/reset.css";
|
||||
// import "./theme/white.css";
|
||||
// TODO: it fails in jest preprocessor now
|
||||
// import "./theme/style.css";
|
||||
// import "./theme/desktop.css";
|
||||
// import "./theme/color.css";
|
||||
|
||||
window.onerror = (
|
||||
msg: string,
|
||||
source: string,
|
||||
lineno: number,
|
||||
colno: number,
|
||||
error: Error
|
||||
) => {
|
||||
const lowerMsg = msg.toLowerCase();
|
||||
if (lowerMsg.indexOf("script error") > -1) {
|
||||
ErrorLogger().error(errCorsScript, "Check Browser Console for Detail");
|
||||
}
|
||||
ErrorLogger().error(`${source}:${lineno}:${colno}: ${error.toString()}`, "");
|
||||
};
|
||||
|
||||
ReactDOM.render(<StateMgr />, document.getElementById("mount"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue