( fn: Function | Function[], instance: ComponentInternalInstance | null, type: ErrorTypes, args?: unknown[], )
| 81 | } |
| 82 | |
| 83 | export function callWithAsyncErrorHandling( |
| 84 | fn: Function | Function[], |
| 85 | instance: ComponentInternalInstance | null, |
| 86 | type: ErrorTypes, |
| 87 | args?: unknown[], |
| 88 | ): any { |
| 89 | if (isFunction(fn)) { |
| 90 | const res = callWithErrorHandling(fn, instance, type, args) |
| 91 | if (res && isPromise(res)) { |
| 92 | res.catch(err => { |
| 93 | handleError(err, instance, type) |
| 94 | }) |
| 95 | } |
| 96 | return res |
| 97 | } |
| 98 | |
| 99 | if (isArray(fn)) { |
| 100 | const values = [] |
| 101 | for (let i = 0; i < fn.length; i++) { |
| 102 | values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)) |
| 103 | } |
| 104 | return values |
| 105 | } else if (__DEV__) { |
| 106 | warn( |
| 107 | `Invalid value type passed to callWithAsyncErrorHandling(): ${typeof fn}`, |
| 108 | ) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | export function handleError( |
| 113 | err: unknown, |
no test coverage detected