fix: do not fail on a bad file name in stack trace (#1120)

This commit is contained in:
Yury Semikhatsky 2022-11-11 18:42:11 -08:00 committed by GitHub
parent 3cc198ea26
commit 1674f95bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,7 +69,13 @@ class StackTraceCollector {
if (file == null) {
return "";
}
return resolveSourcePath(Paths.get(pkg).resolve(file));
try {
// The file name can contain an arbitrary string which may cause Path implementation
// to throw. See https://github.com/microsoft/playwright-java/issues/1115
return resolveSourcePath(Paths.get(pkg).resolve(file));
} catch (RuntimeException e) {
return "";
}
}
private String resolveSourcePath(Path relativePath) {