From 1fd3e0e2a01f9c5deaef9992c2ea4d50bfe513e4 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Fri, 22 Dec 2023 14:02:27 -0500 Subject: [PATCH] Log parsing errors instead of failing (#125) 1. Split the class hierarchy construction front-end parsing error checking into two. 2. Log parsing errors instead of throwing an exception. --- .../python/client/PythonAnalysisEngine.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonAnalysisEngine.java b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonAnalysisEngine.java index 8d1eecdd4..5da40bfb5 100644 --- a/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonAnalysisEngine.java +++ b/com.ibm.wala.cast.python/source/com/ibm/wala/cast/python/client/PythonAnalysisEngine.java @@ -58,7 +58,6 @@ import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.CancelException; import com.ibm.wala.util.WalaException; -import com.ibm.wala.util.WalaRuntimeException; import com.ibm.wala.util.collections.HashMapFactory; import com.ibm.wala.util.collections.HashSetFactory; import java.io.IOException; @@ -66,6 +65,7 @@ import java.util.Collections; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; public abstract class PythonAnalysisEngine @@ -135,17 +135,26 @@ public void buildAnalysisScope() throws IOException { @Override public IClassHierarchy buildClassHierarchy() { + IClassHierarchy cha = null; + try { - IClassHierarchy cha = SeqClassHierarchyFactory.make(scope, loader); - Util.checkForFrontEndErrors(cha); - setClassHierarchy(cha); - return cha; + cha = SeqClassHierarchyFactory.make(scope, loader); } catch (ClassHierarchyException e) { assert false : e; return null; + } + + try { + Util.checkForFrontEndErrors(cha); } catch (WalaException e) { - throw new WalaRuntimeException(e.getMessage(), e); + logger.log( + Level.WARNING, + e, + () -> "Encountered WALA exception, most likely from front-end parsing errors."); } + + setClassHierarchy(cha); + return cha; } protected void addSummaryBypassLogic(AnalysisOptions options, String summary) {