Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reporter and Version-Command: Better error-handling
  • Loading branch information
pesse committed Oct 5, 2018
commit b0ca714605b3f12385ac40050e776f8c3ebd0f02
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.utplsql</groupId>
<artifactId>java-api</artifactId>
<version>3.1.1</version>
<version>3.1.1.1-SNAPSHOT</version>
<scope>compile</scope>
<exclusions>
<exclusion>
Expand Down
17 changes: 13 additions & 4 deletions src/main/java/org/utplsql/cli/ReportersCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import org.utplsql.api.exception.DatabaseNotCompatibleException;
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
import org.utplsql.api.reporter.ReporterFactory;
import org.utplsql.api.reporter.inspect.ReporterInfo;
import org.utplsql.api.reporter.inspect.ReporterInspector;
import org.utplsql.cli.exception.DatabaseConnectionFailed;

import javax.sql.DataSource;
import java.io.PrintStream;
Expand All @@ -21,9 +24,11 @@ public class ReportersCommand implements ICommand {
private List<ConnectionInfo> connectionInfoList = new ArrayList<>();

private ConnectionInfo getConnectionInfo() {
assert connectionInfoList != null;
assert connectionInfoList.size() > 0;
assert connectionInfoList.get(0) != null;
Objects.requireNonNull(connectionInfoList);

if ( connectionInfoList.size() <= 0
|| connectionInfoList.get(0) == null)
throw new IllegalArgumentException("No Connection-Info given");

return connectionInfoList.get(0);
}
Expand All @@ -39,7 +44,11 @@ public int run() {

writeReporters(ReporterInspector.create(reporterFactory, con).getReporterInfos(), System.out);
}
} catch (Exception e) {
}
catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed | IllegalArgumentException e ) {
System.out.println(e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
return 1;
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/utplsql/cli/VersionInfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.utplsql.api.DBHelper;
import org.utplsql.api.JavaApiVersionInfo;
import org.utplsql.api.Version;
import org.utplsql.api.db.DatabaseInformation;
import org.utplsql.api.db.DefaultDatabaseInformation;
import org.utplsql.api.exception.UtPLSQLNotInstalledException;

import javax.sql.DataSource;
Expand Down Expand Up @@ -52,11 +54,11 @@ private void writeUtPlsqlVersion( ConnectionInfo ci ) throws SQLException {
DataSource dataSource = DataSourceProvider.getDataSource(ci, 1);

try (Connection con = dataSource.getConnection()) {
Version v = DBHelper.getDatabaseFrameworkVersion( con );
Version v = new DefaultDatabaseInformation().getUtPlsqlFrameworkVersion(con);
System.out.println("utPLSQL " + v.getNormalizedString());
}
catch ( UtPLSQLNotInstalledException e ) {
System.out.println("utPLSQL framework is not installed in database.");
System.out.println(e.getMessage());
}
}
}
Expand Down