(ex: Error)
| 61 | } |
| 62 | |
| 63 | function serializeStackTrace(ex: Error): string { |
| 64 | // We aren't showing the error message (ex.message) since it might contain PII. |
| 65 | let trace = ''; |
| 66 | for (const frame of parseStack(ex)) { |
| 67 | const filename = frame.getFileName(); |
| 68 | if (filename) { |
| 69 | const lineno = frame.getLineNumber(); |
| 70 | const colno = frame.getColumnNumber(); |
| 71 | trace += `\n\tat ${getCallSite(frame)} ${filename}:${lineno}:${colno}`; |
| 72 | } else { |
| 73 | trace += '\n\tat <anonymous>'; |
| 74 | } |
| 75 | } |
| 76 | // Ensure we always use `/` as path separators. |
| 77 | // This way stack traces (with relative paths) coming from different OS will always look the same. |
| 78 | return trace.trim().replace(/\\/g, '/'); |
| 79 | } |
| 80 | |
| 81 | function getCallSite(frame: stackTrace.StackFrame) { |
| 82 | const parts: string[] = []; |
no test coverage detected