package org.openecomp.sdc.toscaparser.api.common; import org.openecomp.sdc.toscaparser.api.elements.EntityType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; // Perfectly good enough... public class ExceptionCollector { private static Logger log = LoggerFactory.getLogger(ExceptionCollector.class.getName()); private static boolean isCollecting = false; private static ArrayList exceptionStrings = null; private static ArrayList traceStrings = null; private static boolean bWantTrace = true; public static void start() { if(exceptionStrings == null) { exceptionStrings = new ArrayList(); traceStrings = new ArrayList(); } isCollecting = true; } public static void stop() { isCollecting = false; } public static void clear() { exceptionStrings = null; traceStrings = null; } public static void appendException(String strExc) { // throws Exception { if(!isCollecting) { // throw new Exception("Can't append exception " + strExc); log.error("ExceptionCollector - appendException - Can't append exception {}", strExc); } if(!exceptionStrings.contains(strExc)) { exceptionStrings.add(strExc); // get stack trace StackTraceElement[] ste = Thread.currentThread().getStackTrace(); StringBuilder sb = new StringBuilder(); // skip the last 2 (getStackTrace and this) for(int i=2; i getExceptionReport() { if(exceptionStrings.size() > 0) { ArrayList report = new ArrayList<>(); for(int i=0; i