refactor: extract parsing java StackTraceElement to allow improving

This commit is contained in:
Ats Uiboupin 2022-11-18 20:27:44 +02:00 committed by Ats Uiboupin
parent b41f730922
commit e5edb614dd
3 changed files with 66 additions and 4 deletions

View file

@ -0,0 +1,22 @@
export interface StackTraceElement {
tracePath: string
fileName: string
lineStr: string
}
// simple format:
// at <FULLY_QUALIFIED_METHOD_NAME>(<FILE_NAME>:<LINE_NUMBER>)
const re = /^at (.*)\((.*):(\d+)\)$/
export function parseStackTraceElement(stackTraceLine: string): StackTraceElement | undefined {
const match = stackTraceLine.match(re)
if (match !== null) {
const [_, tracePath, fileName, lineStr] = match
return {
tracePath,
fileName,
lineStr
}
}
return undefined
}