Changeset 30


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

+ improved error handling and logging messages

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t3q/src/org/etsi/t3q/T3Q.java

    r7 r30  
    167167                                if (analyzer.getExceptions().size() > 0) { 
    168168                                        String exceptionMessage = "Error while parsing file " 
    169                                                 + analyzer.getFilename();  
     169                                        + analyzer.getFilename();  
     170                                        for (int i1 = 0; i1 < analyzer.getExceptions().size(); i1++) { 
     171                                                String className = analyzer.getExceptions().get(i1).getStackTrace()[0].getClassName(); 
     172                                                String methodName = analyzer.getExceptions().get(i1).getStackTrace()[0].getMethodName(); 
     173                                                exceptionMessage+="\n  "+className.substring(className.lastIndexOf(".")+1)+" : "+methodName; 
     174                                        } 
    170175                                        //TODO: adapt to T3D as well 
    171176                                        String tree = ""; 
     
    392397                        inputPaths.add(arg); 
    393398                } 
    394                  
    395399                return true; 
    396400        } 
     
    587591                                .getInstance(); 
    588592                analyzerFactory.setStandaloneUsage(true); 
     593                System.out.print("  Parsing file: " + filename);  
     594 
    589595                String code = MiscTools.readFile(filename); 
    590                  
    591596                int loc = MiscTools.getLOC(filename); 
    592597                linesOfCodeMap.put(filename, loc); 
    593598                totalLoc += loc; 
    594599 
    595                 System.out.println("  Parsing file: " + filename + " (LOC: " 
    596                                 + linesOfCodeMap.get(filename) + ") ..."); 
     600                System.out.println(" (LOC: "            + linesOfCodeMap.get(filename) + ") ..."); 
    597601                long startTime = System.currentTimeMillis(); 
    598602 
     
    631635 
    632636        public static void main(String[] args) { 
    633                 T3Q tool = new T3Q(); 
    634                 tool.run(args); 
     637                try{ 
     638                        T3Q tool = new T3Q(); 
     639                        tool.run(args); 
     640                } catch (Exception e) { 
     641                        if (getLogLevel()==LogLevel.DEBUG){ 
     642                                e.printStackTrace(); 
     643                                 
     644                        } else { 
     645                                String stacktrace = ""; 
     646                                for (StackTraceElement ste : e.getStackTrace()){ 
     647                                        stacktrace+="\n    "+ste.toString(); 
     648                                } 
     649                                System.err.println("ERROR: A problem occurred while running T3Q" + 
     650                                                "\n  Problem type: " +  
     651                                                e + 
     652                                                "\n  Stacktrace:" + 
     653                                                stacktrace +  
     654                                                "\n  Run T3Q with --verbosity=DEBUG for a more detailed report" ); 
     655                        } 
     656                } 
    635657        } 
    636658        //TODO: DUPLICATED IN T3D 
Note: See TracChangeset for help on using the changeset viewer.