Changeset 32


Ignore:
Timestamp:
05/08/11 18:07:33 (13 years ago)
Author:
phdmakk
Message:

+ improved error handling and logging messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t3d/src/org/etsi/t3d/T3D.java

    r7 r32  
    192192                                                .get(i)); 
    193193                                if (analyzer.getExceptions().size() > 0) { 
     194                                        String exceptionMessage = "Error while parsing file " 
     195                                                + analyzer.getFilename();  
     196                                        for (int i1 = 0; i1 < analyzer.getExceptions().size(); i1++) { 
     197                                                String className = analyzer.getExceptions().get(i1).getStackTrace()[0].getClassName(); 
     198                                                String methodName = analyzer.getExceptions().get(i1).getStackTrace()[0].getMethodName(); 
     199                                                exceptionMessage+="\n  "+className.substring(className.lastIndexOf(".")+1)+" : "+methodName; 
     200                                        } 
    194201 
    195202                                        // TODO: in eclipse the error stream seems to be delayed 
     
    198205                                        // -> The terminal seems to handle this properly in contrast 
    199206                                        if (T3D.activeProfile.isSettingAbortOnError()) { 
    200                                                 throw new TTCN3ParserException( 
    201                                                                 "Error while parsing file " 
    202                                                                                 + analyzer.getFilename()); 
     207                                                throw new TTCN3ParserException(exceptionMessage); 
    203208                                        } else { 
    204209                                                try { 
    205                                                         throw new TTCN3ParserException( 
    206                                                                         "Error while parsing file " 
    207                                                                                         + analyzer.getFilename()); 
     210                                                        throw new TTCN3ParserException(exceptionMessage); 
    208211                                                } catch (TTCN3ParserException e) { 
    209212                                                        System.err.println(e.getLocalizedMessage()); 
     
    708711                                .getInstance(); 
    709712                analyzerFactory.setStandaloneUsage(true); 
     713                System.out.print("  Parsing file: " + filename);  
     714                 
    710715                String code = MiscTools.readFile(filename); 
    711  
    712716                int loc = MiscTools.getLOC(filename); 
    713717                linesOfCodeMap.put(filename, loc); 
    714718                totalLoc += loc; 
    715719 
    716                 System.out.println("  Parsing file: " + filename + " (LOC: " 
    717                                 + linesOfCodeMap.get(filename) + ") ..."); 
     720                System.out.println(" (LOC: "            + linesOfCodeMap.get(filename) + ") ..."); 
    718721                long startTime = System.currentTimeMillis(); 
    719722 
     
    752755 
    753756        public static void main(String[] args) { 
    754                 T3D tool = new T3D(); 
    755                 tool.run(args); 
     757                try{ 
     758                        T3D tool = new T3D(); 
     759                        tool.run(args); 
     760                } catch (Exception e) { 
     761                        if (getLogLevel()==LogLevel.DEBUG){ 
     762                                e.printStackTrace(); 
     763                                 
     764                        } else { 
     765                                String stacktrace = ""; 
     766                                for (StackTraceElement ste : e.getStackTrace()){ 
     767                                        stacktrace+="\n    "+ste.toString(); 
     768                                } 
     769                                System.err.println("ERROR: A problem occurred while running T3Q" + 
     770                                                "\n  Problem type: " +  
     771                                                e + 
     772                                                "\n  Stacktrace:" + 
     773                                                stacktrace +  
     774                                                "\n  Run T3Q with --verbosity=DEBUG for a more detailed report" ); 
     775                        } 
     776                } 
    756777        } 
    757778        //TODO: DUPLICATE 
Note: See TracChangeset for help on using the changeset viewer.