( err: unknown, type: ErrorTypes, contextVNode: VNode | null, throwInDev = true, throwInProd = false, )
| 155 | } |
| 156 | |
| 157 | function logError( |
| 158 | err: unknown, |
| 159 | type: ErrorTypes, |
| 160 | contextVNode: VNode | null, |
| 161 | throwInDev = true, |
| 162 | throwInProd = false, |
| 163 | ) { |
| 164 | if (__DEV__) { |
| 165 | const info = ErrorTypeStrings[type] |
| 166 | if (contextVNode) { |
| 167 | pushWarningContext(contextVNode) |
| 168 | } |
| 169 | warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`) |
| 170 | if (contextVNode) { |
| 171 | popWarningContext() |
| 172 | } |
| 173 | // crash in dev by default so it's more noticeable |
| 174 | if (throwInDev) { |
| 175 | throw err |
| 176 | } else if (!__TEST__) { |
| 177 | console.error(err) |
| 178 | } |
| 179 | } else if (throwInProd) { |
| 180 | throw err |
| 181 | } else { |
| 182 | // recover in prod to reduce the impact on end-user |
| 183 | console.error(err) |
| 184 | } |
| 185 | } |
no test coverage detected