(message: string, node: Node)
| 24 | ) |
| 25 | |
| 26 | export const printErrorWithNodeDetails = (message: string, node: Node) => { |
| 27 | const stack = getMeta(node, 'unitTrace') |
| 28 | const config = getMeta(node, 'config') |
| 29 | const locString = config?.loc |
| 30 | ? ` at ${config.loc.file}` |
| 31 | : null |
| 32 | const name = config?.name |
| 33 | |
| 34 | let finalMessage = message |
| 35 | if (name) { |
| 36 | finalMessage = `${name}: ${message}` |
| 37 | } |
| 38 | if (locString) { |
| 39 | finalMessage = `${name}${locString}: ${message}` |
| 40 | } |
| 41 | |
| 42 | const error = Error(finalMessage) |
| 43 | |
| 44 | if (stack) { |
| 45 | error.stack = stack |
| 46 | } |
| 47 | |
| 48 | if (!stack && !name && !locString) { |
| 49 | console.log( |
| 50 | `Add effector's Babel or SWC plugin to your config for more detailed debug information or "import "effector/enable_debug_traces" to your code entry module to see full stack traces`, |
| 51 | ) |
| 52 | } |
| 53 | console.error(error) |
| 54 | } |
no test coverage detected
searching dependent graphs…