fix(log): prevent thowing on failed to get caller location (#2157)

* Fix failed to get caller location throws

* Add change file

* typo

* build

* Bump log rs

* typo

* early return instead of using ?
This commit is contained in:
Tony
2024-12-07 19:32:47 +08:00
committed by GitHub
parent fe610d6759
commit 69d508ee69
3 changed files with 12 additions and 3 deletions
+5 -2
View File
@@ -60,7 +60,10 @@ function getCallerLocation(stack?: string) {
const lines = stack.split('\n')
// Find the third line (caller's caller of the current location)
const callerLine = lines[3].trim()
const callerLine = lines[3]?.trim()
if (!callerLine) {
return
}
const regex =
/at\s+(?<functionName>.*?)\s+\((?<fileName>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+)\)/
@@ -103,7 +106,7 @@ function getCallerLocation(stack?: string) {
return name.length > 0 && location !== '[native code]'
})
// Find the third line (caller's caller of the current location)
return filtered[2].filter((v) => v.length > 0).join('@')
return filtered[2]?.filter((v) => v.length > 0).join('@')
}
}