File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed
src/main/java/org/utplsql/cli Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 4
4
import com .beust .jcommander .Parameter ;
5
5
import com .beust .jcommander .ParameterException ;
6
6
import org .utplsql .api .exception .DatabaseNotCompatibleException ;
7
+ import org .utplsql .api .exception .UtPLSQLNotInstalledException ;
8
+ import org .utplsql .cli .exception .DatabaseConnectionFailed ;
7
9
8
10
public class Cli {
9
11
@@ -35,7 +37,7 @@ public static void main(String[] args) {
35
37
} else {
36
38
jc .usage ();
37
39
}
38
- } catch ( DatabaseNotCompatibleException e ) {
40
+ } catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed e ) {
39
41
System .out .println (e .getMessage ());
40
42
} catch (Exception e ) {
41
43
e .printStackTrace ();
Original file line number Diff line number Diff line change 8
8
import org .utplsql .api .exception .SomeTestsFailedException ;
9
9
import org .utplsql .api .reporter .Reporter ;
10
10
import org .utplsql .api .reporter .ReporterFactory ;
11
+ import org .utplsql .cli .exception .DatabaseConnectionFailed ;
11
12
12
13
import java .io .File ;
13
14
import java .io .FileNotFoundException ;
@@ -120,8 +121,12 @@ public int run() throws Exception {
120
121
reporterList = initReporters (conn , reporterOptionsList );
121
122
122
123
} catch (SQLException e ) {
123
- System .out .println (e .getMessage ());
124
- return Cli .DEFAULT_ERROR_CODE ;
124
+ if ( e .getErrorCode () == 1017 || e .getErrorCode () == 12514 ) {
125
+ throw new DatabaseConnectionFailed (e );
126
+ }
127
+ else {
128
+ throw e ;
129
+ }
125
130
}
126
131
127
132
ExecutorService executorService = Executors .newFixedThreadPool (1 + reporterList .size ());
Original file line number Diff line number Diff line change
1
+ package org .utplsql .cli .exception ;
2
+
3
+ import java .sql .SQLException ;
4
+
5
+ public class DatabaseConnectionFailed extends SQLException {
6
+
7
+ public DatabaseConnectionFailed (SQLException cause ) {
8
+ super ( "Could not establish connection to database. Reason: " + cause .getMessage (), cause );
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments