Line data Source code
1 2356 : const presentedGraphLoadFailures = new WeakSet<object>()
2 :
3 6 : function normaliseGraphLoadFailure(error: unknown): Error {
4 6 : if (error instanceof Error) return error
5 6 : return new Error(typeof error === 'string' ? error : String(error))
6 : }
7 :
8 6 : export function markGraphLoadFailurePresented(error: unknown): Error {
9 6 : const failure = normaliseGraphLoadFailure(error)
10 6 : presentedGraphLoadFailures.add(failure)
11 6 : return failure
12 : }
13 :
14 0 : export function isGraphLoadFailurePresented(error: unknown): boolean {
15 0 : return (
16 : typeof error === 'object' &&
17 : error !== null &&
18 : presentedGraphLoadFailures.has(error)
19 : )
20 : }
|