MCPcopy Create free account
hub / github.com/dailydotdev/apps / useError

Function useError

packages/shared/src/hooks/useError.ts:6–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { onDomMutationGuarded } from '../lib/domMutationGuard';
5
6export function useError(): void {
7 const { logEvent } = useLogContext();
8
9 useEffect(() => {
10 if (!logEvent) {
11 return undefined;
12 }
13
14 window.onerror = (msg, url, line, col, error) => {
15 logEvent({
16 event_name: LogEvent.GlobalError,
17 extra: JSON.stringify({
18 msg,
19 url,
20 line,
21 col,
22 error,
23 }),
24 });
25 };
26
27 return onDomMutationGuarded((method) => {
28 logEvent({
29 event_name: LogEvent.GlobalError,
30 extra: JSON.stringify({
31 msg: `Skipped ${method}: the node is not a child of this node`,
32 url: window.location.href,
33 domMutation: true,
34 }),
35 });
36 });
37 }, [logEvent]);
38}

Callers 3

AppFunction · 0.90
AppFunction · 0.90
InternalAppFunction · 0.90

Calls 3

useLogContextFunction · 0.90
onDomMutationGuardedFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected