(fn: Fn)
| 71 | * @returns A new function that executes the original function and logs any errors. Returns undefined in case of an error. |
| 72 | */ |
| 73 | export function catchInternal<Fn extends (...args: any[]) => any>(fn: Fn): (...args: Parameters<Fn>) => Promise<ReturnType<Fn> | undefined> { |
| 74 | return async (...args: any[]) => { |
| 75 | try { |
| 76 | return await fn(...args) |
| 77 | } catch (error) { |
| 78 | console.error('Internal error caught:', error) |
| 79 | |
| 80 | if (globalNotificationCallback) { |
| 81 | const errorMessage = 'An internal error occurred. Please try again or check the console for details. ' + (error instanceof Error ? String(error.message).slice(0, 50) : '') |
| 82 | globalNotificationCallback({ |
| 83 | message: errorMessage, |
| 84 | type: 'error', |
| 85 | duration: 5000 |
| 86 | }) |
| 87 | } |
| 88 | |
| 89 | return undefined |
| 90 | } |
| 91 | } |
| 92 | } |
no outgoing calls
no test coverage detected