Skip to content

Commit

Permalink
[JsSrc2Cpg] - Handle runtime exception gracefully when filtering astG…
Browse files Browse the repository at this point in the history
…en result (#5281)
  • Loading branch information
khemrajrathore authored Feb 5, 2025
1 parent cd84cd9 commit 94d91b6
Showing 1 changed file with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,23 @@ class AstGenRunner(config: Config) {

private def filterFiles(files: List[String], out: File): List[String] = {
files.filter { file =>
file.stripSuffix(".json").replace(out.pathAsString, config.inputPath) match {
// We are not interested in JS / TS type definition files at this stage.
// TODO: maybe we can enable that later on and use the type definitions there
// for enhancing the CPG with additional type information for functions
case filePath if TypeDefinitionFileExtensions.exists(filePath.endsWith) => false
case filePath if isIgnoredByUserConfig(filePath) => false
case filePath if isIgnoredByDefault(filePath) => false
case filePath if isTranspiledFile(filePath) => false
case _ => true
Try {
file.stripSuffix(".json").replace(out.pathAsString, config.inputPath) match {
// We are not interested in JS / TS type definition files at this stage.
// TODO: maybe we can enable that later on and use the type definitions there
// for enhancing the CPG with additional type information for functions
case filePath if TypeDefinitionFileExtensions.exists(filePath.endsWith) => false
case filePath if isIgnoredByUserConfig(filePath) => false
case filePath if isIgnoredByDefault(filePath) => false
case filePath if isTranspiledFile(filePath) => false
case _ => true
}
} match {
case Success(result) => result
case Failure(exception) =>
// Log the exception for debugging purposes
logger.error("An error occurred while processing the file path during filtering file stage : ", exception)
false
}
}
}
Expand Down

0 comments on commit 94d91b6

Please sign in to comment.