mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2025-12-06 00:20:05 +01:00
Error handler out of scope
This commit is contained in:
parent
acc77cd878
commit
8198e0a61a
|
|
@ -1,14 +1,14 @@
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { haltEvent } from "utils/functions";
|
import { haltEvent } from "utils/functions";
|
||||||
|
|
||||||
|
const errorHandler = (event: Event & { error: Error }): void => {
|
||||||
|
if (event.error?.stack?.includes("eval at <anonymous>")) {
|
||||||
|
haltEvent(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const useGlobalErrorHandler = (): void => {
|
const useGlobalErrorHandler = (): void => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const errorHandler = (event: Event & { error: Error }): void => {
|
|
||||||
if (event.error?.stack?.includes("eval at <anonymous>")) {
|
|
||||||
haltEvent(event);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener("error", errorHandler);
|
window.addEventListener("error", errorHandler);
|
||||||
|
|
||||||
return () => window.removeEventListener("error", errorHandler);
|
return () => window.removeEventListener("error", errorHandler);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user