22
33import com .beust .jcommander .Parameter ;
44import com .beust .jcommander .Parameters ;
5+ import org .utplsql .api .exception .DatabaseNotCompatibleException ;
6+ import org .utplsql .api .exception .UtPLSQLNotInstalledException ;
57import org .utplsql .api .reporter .ReporterFactory ;
68import org .utplsql .api .reporter .inspect .ReporterInfo ;
79import org .utplsql .api .reporter .inspect .ReporterInspector ;
10+ import org .utplsql .cli .exception .DatabaseConnectionFailed ;
811
912import javax .sql .DataSource ;
1013import java .io .PrintStream ;
@@ -21,9 +24,11 @@ public class ReportersCommand implements ICommand {
2124 private List <ConnectionInfo > connectionInfoList = new ArrayList <>();
2225
2326 private ConnectionInfo getConnectionInfo () {
24- assert connectionInfoList != null ;
25- assert connectionInfoList .size () > 0 ;
26- assert connectionInfoList .get (0 ) != null ;
27+ Objects .requireNonNull (connectionInfoList );
28+
29+ if ( connectionInfoList .size () <= 0
30+ || connectionInfoList .get (0 ) == null )
31+ throw new IllegalArgumentException ("No Connection-Info given" );
2732
2833 return connectionInfoList .get (0 );
2934 }
@@ -39,7 +44,11 @@ public int run() {
3944
4045 writeReporters (ReporterInspector .create (reporterFactory , con ).getReporterInfos (), System .out );
4146 }
42- } catch (Exception e ) {
47+ }
48+ catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed | IllegalArgumentException e ) {
49+ System .out .println (e .getMessage ());
50+ }
51+ catch (Exception e ) {
4352 e .printStackTrace ();
4453 return 1 ;
4554 }
@@ -52,15 +61,7 @@ public String getCommand() {
5261 return "reporters" ;
5362 }
5463
55- private int getMaxNameLength (List <ReporterInfo > reporterInfos ) {
56- return reporterInfos .stream ()
57- .mapToInt (info -> info .getName ().length ())
58- .max ()
59- .orElse (0 );
60- }
61-
6264 private void writeReporters (List <ReporterInfo > reporterInfos , PrintStream out ) {
63- //int padding = getMaxNameLength(reporterInfos)+1;
6465 reporterInfos .stream ()
6566 .sorted (Comparator .comparing (ReporterInfo ::getName ))
6667 .forEach (info -> writeReporter (info , 4 , out ));
0 commit comments