Skip to content

Commit 326a2aa

Browse files
committed
#407: remove the solver-specific Z3SolverException.
The specific exception does not bring any benefit over a default SolverException.
1 parent 17bf744 commit 326a2aa

File tree

4 files changed

+9
-29
lines changed

4 files changed

+9
-29
lines changed

src/org/sosy_lab/java_smt/solvers/z3/Z3AbstractProver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ void addParameter(long z3params, String key, Object value) {
8989
}
9090

9191
/** dump the current solver stack into a new SMTLIB file. */
92-
protected void logSolverStack() throws Z3SolverException {
92+
protected void logSolverStack() throws SolverException {
9393
if (logfile != null) { // if logging is not disabled
9494
try {
9595
// write stack content to logfile
9696
Path filename = logfile.getFreshPath();
9797
MoreFiles.createParentDirectories(filename);
9898
Files.writeString(filename, this + "(check-sat)\n");
9999
} catch (IOException e) {
100-
throw new Z3SolverException("Cannot write Z3 log file: " + e.getMessage());
100+
throw new SolverException("Cannot write Z3 log file", e);
101101
}
102102
}
103103
}

src/org/sosy_lab/java_smt/solvers/z3/Z3OptimizationProver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public int minimize(Formula objective) {
7272
}
7373

7474
@Override
75-
public OptStatus check() throws InterruptedException, Z3SolverException {
75+
public OptStatus check() throws InterruptedException, SolverException {
7676
Preconditions.checkState(!closed);
7777
int status;
7878
try {
@@ -132,7 +132,7 @@ protected long getUnsatCore0() {
132132
}
133133

134134
@Override
135-
public boolean isUnsat() throws Z3SolverException, InterruptedException {
135+
public boolean isUnsat() throws SolverException, InterruptedException {
136136
Preconditions.checkState(!closed);
137137
logSolverStack();
138138
return check() == OptStatus.UNSAT;

src/org/sosy_lab/java_smt/solvers/z3/Z3SolverException.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/org/sosy_lab/java_smt/solvers/z3/Z3TheoremProver.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.sosy_lab.java_smt.api.BooleanFormula;
2424
import org.sosy_lab.java_smt.api.ProverEnvironment;
2525
import org.sosy_lab.java_smt.api.SolverContext.ProverOptions;
26+
import org.sosy_lab.java_smt.api.SolverException;
2627
import org.sosy_lab.java_smt.api.UserPropagator;
2728

2829
class Z3TheoremProver extends Z3AbstractProver implements ProverEnvironment {
@@ -82,7 +83,7 @@ protected void assertContraintAndTrack(long constraint, long symbol) {
8283
}
8384

8485
@Override
85-
public boolean isUnsat() throws Z3SolverException, InterruptedException {
86+
public boolean isUnsat() throws SolverException, InterruptedException {
8687
Preconditions.checkState(!closed);
8788
logSolverStack();
8889
int result;
@@ -97,7 +98,7 @@ public boolean isUnsat() throws Z3SolverException, InterruptedException {
9798

9899
@Override
99100
public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions)
100-
throws Z3SolverException, InterruptedException {
101+
throws SolverException, InterruptedException {
101102
Preconditions.checkState(!closed);
102103

103104
int result;
@@ -116,7 +117,7 @@ public boolean isUnsatWithAssumptions(Collection<BooleanFormula> assumptions)
116117
}
117118

118119
private void undefinedStatusToException(int solverStatus)
119-
throws Z3SolverException, InterruptedException {
120+
throws SolverException, InterruptedException {
120121
if (solverStatus == Z3_lbool.Z3_L_UNDEF.toInt()) {
121122
creator.shutdownNotifier.shutdownIfNecessary();
122123
final String reason = Native.solverGetReasonUnknown(z3context, z3solver);
@@ -126,7 +127,7 @@ private void undefinedStatusToException(int solverStatus)
126127
case "interrupted from keyboard": // see Z3: src/solver/check_sat_result.cpp
127128
throw new InterruptedException(reason);
128129
default:
129-
throw new Z3SolverException("Solver returned 'unknown' status, reason: " + reason);
130+
throw new SolverException("Z3 returned 'unknown' status, reason: " + reason);
130131
}
131132
}
132133
}

0 commit comments

Comments
 (0)