Skip to content

Commit f63774a

Browse files
pesseSamuel Nitsche
authored andcommitted
Introduce special Exception for when utPLSQL is not installed
1 parent 8f4e2e0 commit f63774a

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/main/java/org/utplsql/api/DBHelper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import oracle.jdbc.OracleTypes;
44
import org.utplsql.api.exception.DatabaseNotCompatibleException;
5+
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
56

67
import java.sql.*;
78

@@ -67,6 +68,11 @@ public static Version getDatabaseFrameworkVersion( Connection conn )
6768
result = new Version(rs.getString(1));
6869

6970
rs.close();
71+
} catch ( SQLException e ) {
72+
if ( e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE )
73+
throw new UtPLSQLNotInstalledException(e);
74+
else
75+
throw e;
7076
}
7177

7278
return result;

src/main/java/org/utplsql/api/TestRunner.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.utplsql.api.compatibility.CompatibilityProxy;
55
import org.utplsql.api.exception.DatabaseNotCompatibleException;
66
import org.utplsql.api.exception.SomeTestsFailedException;
7+
import org.utplsql.api.exception.UtPLSQLNotInstalledException;
78
import org.utplsql.api.reporter.DocumentationReporter;
89
import org.utplsql.api.reporter.Reporter;
910
import org.utplsql.api.testRunner.TestRunnerStatement;
@@ -84,7 +85,7 @@ public TestRunner skipCompatibilityCheck( boolean skipCompatibilityCheck )
8485
return this;
8586
}
8687

87-
public void run(Connection conn) throws SomeTestsFailedException, SQLException, DatabaseNotCompatibleException {
88+
public void run(Connection conn) throws SomeTestsFailedException, SQLException, DatabaseNotCompatibleException, UtPLSQLNotInstalledException {
8889

8990
CompatibilityProxy compatibilityProxy = new CompatibilityProxy(conn, options.skipCompatibilityCheck);
9091

@@ -113,7 +114,11 @@ public void run(Connection conn) throws SomeTestsFailedException, SQLException,
113114
} catch (SQLException e) {
114115
if (e.getErrorCode() == SomeTestsFailedException.ERROR_CODE) {
115116
throw new SomeTestsFailedException(e.getMessage(), e);
116-
} else {
117+
}
118+
else if (e.getErrorCode() == UtPLSQLNotInstalledException.ERROR_CODE) {
119+
throw new UtPLSQLNotInstalledException(e);
120+
}
121+
else {
117122
// If the execution failed by unexpected reasons finishes all reporters,
118123
// this way the users don't need to care about reporters' sessions hanging.
119124
OracleConnection oraConn = conn.unwrap(OracleConnection.class);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.utplsql.api.exception;
2+
3+
import java.sql.SQLException;
4+
5+
/** Exception to track when utPLSQL framework is not installed or accessible on the used database
6+
*
7+
* @author pesse
8+
*/
9+
public class UtPLSQLNotInstalledException extends SQLException {
10+
11+
public static final int ERROR_CODE = 904;
12+
13+
public UtPLSQLNotInstalledException( SQLException cause ) {
14+
super("utPLSQL framework is not installed on your database or not accessable to the user you are connected with", cause);
15+
}
16+
}

0 commit comments

Comments
 (0)