(msg, location, e)
| 29 | } |
| 30 | |
| 31 | export function error (msg, location, e) { |
| 32 | const workInProgress = global.workInProgress |
| 33 | let stack = '' |
| 34 | if (workInProgress) { |
| 35 | stack = getStackByFiberInDevAndProd(workInProgress) |
| 36 | } |
| 37 | const errorHandler = mpxGlobal.__mpx?.config.errorHandler |
| 38 | if (!e) { |
| 39 | e = new Error(stack ? `${msg}\n Error Component Stack:${stack}` : msg) |
| 40 | } else { |
| 41 | if (stack) { |
| 42 | if (type(e) === 'Error') { |
| 43 | e.message += `\n Error Component Stack:${stack}` |
| 44 | } |
| 45 | if (type(e) === 'String') { |
| 46 | e += `\n Error Component Stack:${stack}` |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | if (isFunction(errorHandler)) { |
| 51 | errorHandler(msg, location, e) |
| 52 | } else { |
| 53 | log('error', msg, location, e) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | function log (type, msg, location, e) { |
| 58 | if (isDev) { |
no test coverage detected