Skip to content

Commit

Permalink
use std::exception as base class to z3_exception
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <[email protected]>
  • Loading branch information
NikolajBjorner committed Nov 4, 2024
1 parent 1957b4d commit 9206546
Show file tree
Hide file tree
Showing 60 changed files with 109 additions and 111 deletions.
8 changes: 4 additions & 4 deletions src/api/api_config_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern "C" {
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
warning_msg("%s", ex.what());
}
}

Expand All @@ -59,7 +59,7 @@ extern "C" {
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
warning_msg("%s", ex.what());
return false;
}
}
Expand All @@ -84,7 +84,7 @@ extern "C" {
} catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
warning_msg("%s", ex.what());
return nullptr;
}
}
Expand All @@ -106,7 +106,7 @@ extern "C" {
catch (z3_exception & ex) {
// The error handler is only available for contexts
// Just throw a warning.
warning_msg("%s", ex.msg());
warning_msg("%s", ex.what());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/api_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ namespace api {
set_error_code(Z3_MEMOUT_FAIL, nullptr);
break;
case ERR_PARSER:
set_error_code(Z3_PARSER_ERROR, ex.msg());
set_error_code(Z3_PARSER_ERROR, ex.what());
break;
case ERR_INI_FILE:
set_error_code(Z3_INVALID_ARG, nullptr);
Expand All @@ -320,7 +320,7 @@ namespace api {
}
}
else {
set_error_code(Z3_EXCEPTION, ex.msg());
set_error_code(Z3_EXCEPTION, ex.what());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/api/api_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extern "C" {
}
r = l_undef;
if (!mk_c(c)->m().inc()) {
to_optimize_ptr(o)->set_reason_unknown(ex.msg());
to_optimize_ptr(o)->set_reason_unknown(ex.what());
}
else {
mk_c(c)->handle_exception(ex);
Expand Down Expand Up @@ -364,7 +364,7 @@ extern "C" {
}
}
catch (z3_exception& e) {
errstrm << e.msg();
errstrm << e.what();
ctx = nullptr;
SET_ERROR_CODE(Z3_PARSER_ERROR, errstrm.str());
return;
Expand Down
4 changes: 2 additions & 2 deletions src/api/api_parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ extern "C" {
catch (z3_exception& e) {
if (owned)
ctx = nullptr;
errstrm << e.msg();
errstrm << e.what();
SET_ERROR_CODE(Z3_PARSER_ERROR, errstrm.str());
return of_ast_vector(v);
}
Expand Down Expand Up @@ -257,7 +257,7 @@ extern "C" {
}
}
catch (z3_exception& e) {
if (ous.str().empty()) ous << e.msg();
if (ous.str().empty()) ous << e.what();
SET_ERROR_CODE(Z3_PARSER_ERROR, ous.str());
RETURN_Z3(mk_c(c)->mk_external_string(ous.str()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/api/z3_replayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ struct z3_replayer::imp {
throw;
}
catch (z3_exception & ex) {
std::cout << "[z3 exception]: " << ex.msg() << std::endl;
std::cout << "[z3 exception]: " << ex.what() << std::endl;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ bool ast_manager::check_sorts(ast const * n) const {
return true;
}
catch (ast_exception & ex) {
warning_msg("%s", ex.msg());
warning_msg("%s", ex.what());
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ast/sls/sat_ddfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace sat {
}
}
catch (z3_exception& ex) {
IF_VERBOSE(0, verbose_stream() << "Exception: " << ex.msg() << "\n");
IF_VERBOSE(0, verbose_stream() << "Exception: " << ex.what() << "\n");
throw;
}
m_plugin->finish_search();
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_context/basic_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ class set_option_cmd : public set_get_option_cmd {
ctx.global_params_updated();
}
catch (const gparams::exception & ex) {
throw cmd_exception(ex.msg());
throw cmd_exception(ex.what());
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/cmd_context/cmd_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1605,7 +1605,7 @@ void cmd_context::push() {
throw ex;
}
catch (z3_exception & ex) {
throw cmd_exception(ex.msg());
throw cmd_exception(ex.what());
}
}

Expand Down Expand Up @@ -1768,7 +1768,7 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions
throw ex;
}
catch (z3_exception & ex) {
throw cmd_exception(ex.msg());
throw cmd_exception(ex.what());
}
get_opt()->set_status(r);
}
Expand All @@ -1793,7 +1793,7 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions
m_solver->set_reason_unknown(eh);
}
else {
m_solver->set_reason_unknown(ex.msg());
m_solver->set_reason_unknown(ex.what());
}
r = l_undef;
}
Expand Down Expand Up @@ -1832,7 +1832,7 @@ void cmd_context::get_consequences(expr_ref_vector const& assumptions, expr_ref_
throw ex;
}
catch (z3_exception & ex) {
m_solver->set_reason_unknown(ex.msg());
m_solver->set_reason_unknown(ex.what());
r = l_undef;
}
m_solver->set_status(r);
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_context/eval_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class eval_cmd : public parametric_cmd {
ev(m_target, r);
}
catch (model_evaluator_exception & ex) {
ctx.regular_stream() << "(error \"evaluator failed: " << ex.msg() << "\")" << std::endl;
ctx.regular_stream() << "(error \"evaluator failed: " << ex.what() << "\")" << std::endl;
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd_context/simplify_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class simplify_cmd : public parametric_cmd {
throw ex;
}
catch (z3_exception & ex) {
ctx.regular_stream() << "(error \"simplifier failed: " << ex.msg() << "\")" << std::endl;
ctx.regular_stream() << "(error \"simplifier failed: " << ex.what() << "\")" << std::endl;
failed = true;
r = m_target;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd_context/tactic_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ class check_sat_using_tactic_cmd : public exec_given_tactic_cmd {
}
catch (z3_exception & ex) {
result->set_status(l_undef);
result->m_unknown = ex.msg();
ctx.regular_stream() << "(error \"tactic failed: " << ex.msg() << "\")" << std::endl;
result->m_unknown = ex.what();
ctx.regular_stream() << "(error \"tactic failed: " << ex.what() << "\")" << std::endl;
}
ctx.validate_check_sat_result(r);
}
Expand Down Expand Up @@ -321,7 +321,7 @@ class apply_tactic_cmd : public exec_given_tactic_cmd {
exec(t, g, result_goals);
}
catch (tactic_exception & ex) {
ctx.regular_stream() << "(error \"tactic failed: " << ex.msg() << "\")" << std::endl;
ctx.regular_stream() << "(error \"tactic failed: " << ex.what() << "\")" << std::endl;
failed = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/math/subpaving/tactic/subpaving_tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class subpaving_tactic : public tactic {
}
catch (z3_exception & ex) {
// convert all Z3 exceptions into tactic exceptions
throw tactic_exception(ex.msg());
throw tactic_exception(ex.what());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool model::eval_expr(expr * e, expr_ref & result, bool model_completion) {
}
catch (model_evaluator_exception & ex) {
(void)ex;
TRACE("model_evaluator", tout << ex.msg() << "\n";);
TRACE("model_evaluator", tout << ex.what() << "\n";);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/model_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ bool model_evaluator::eval(expr* t, expr_ref& r, bool model_completion) {
}
catch (model_evaluator_exception &ex) {
(void)ex;
TRACE("model_evaluator", tout << ex.msg () << "\n";);
TRACE("model_evaluator", tout << ex.what () << "\n";);
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/muz/fp/datalog_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class dparser : public parser {
result = tok == TK_EOS && m_error == false;
}
catch (z3_exception& ex) {
std::cerr << ex.msg() << std::endl;
std::cerr << ex.what() << std::endl;
result = false;
}
return result;
Expand Down Expand Up @@ -1225,7 +1225,7 @@ class wpa_parser_impl : public wpa_parser, dparser {
result = parse_directory_core(path);
}
catch (z3_exception& ex) {
std::cerr << ex.msg() << std::endl;
std::cerr << ex.what() << std::endl;
return false;
}
return result;
Expand Down
4 changes: 2 additions & 2 deletions src/muz/fp/dl_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ class dl_query_cmd : public parametric_cmd {
status = dlctx.rel_query(1, &m_target);
}
catch (z3_error & ex) {
ctx.regular_stream() << "(error \"query failed: " << ex.msg() << "\")" << std::endl;
ctx.regular_stream() << "(error \"query failed: " << ex.what() << "\")" << std::endl;
print_statistics(ctx);
throw ex;
}
catch (z3_exception& ex) {
ctx.regular_stream() << "(error \"query failed: " << ex.msg() << "\")" << std::endl;
ctx.regular_stream() << "(error \"query failed: " << ex.what() << "\")" << std::endl;
query_exn = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/muz/fp/horn_tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class horn_tactic : public tactic {
is_reachable = m_ctx.query(q);
}
catch (default_exception& ex) {
IF_VERBOSE(1, verbose_stream() << ex.msg() << "\n";);
IF_VERBOSE(1, verbose_stream() << ex.what() << "\n";);
throw ex;
}
g->inc_depth();
Expand Down
2 changes: 1 addition & 1 deletion src/nlsat/tactic/nlsat_tactic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class nlsat_tactic : public tactic {
}
catch (z3_exception & ex) {
// convert all Z3 exceptions into tactic exceptions.
throw tactic_exception(ex.msg());
throw tactic_exception(ex.what());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/opt/maxsmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ namespace opt {
is_sat = (*m_msolver)();
}
catch (z3_exception& ex) {
IF_VERBOSE(1, verbose_stream() << ex.msg() << "\n");
IF_VERBOSE(1, verbose_stream() << ex.what() << "\n");
is_sat = l_undef;
}
if (is_sat != l_false) {
Expand Down
18 changes: 9 additions & 9 deletions src/parsers/smt2/smt2parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ namespace smt2 {
}
catch (scanner_exception & ex) {
if (ex.has_pos())
error(ex.line(), ex.pos(), ex.msg());
error(ex.line(), ex.pos(), ex.what());
++num_errors;
}
}
Expand Down Expand Up @@ -3146,7 +3146,7 @@ namespace smt2 {
}
}
catch (z3_exception & ex) {
error(ex.msg());
error(ex.what());
}
return sexpr_ref(nullptr, sm());
}
Expand All @@ -3162,7 +3162,7 @@ namespace smt2 {
return sort_ref(sort_stack().back(), m());
}
catch (z3_exception & ex) {
error(ex.msg());
error(ex.what());
}
return sort_ref(nullptr, m());
}
Expand All @@ -3176,7 +3176,7 @@ namespace smt2 {
scan_core();
}
catch (scanner_exception & ex) {
error(ex.msg());
error(ex.what());
if (!sync_after_error())
return false;
found_errors++;
Expand All @@ -3202,7 +3202,7 @@ namespace smt2 {
// Can't invoke error(...) when out of memory.
// Reason: escaped() string builder needs memory
m_ctx.regular_stream() << "(error \"line " << m_scanner.get_line() << " column " << m_scanner.get_pos()
<< ": " << ex.msg() << "\")" << std::endl;
<< ": " << ex.what() << "\")" << std::endl;
exit(ex.error_code());
}
catch (const stop_parser_exception &) {
Expand All @@ -3211,15 +3211,15 @@ namespace smt2 {
}
catch (parser_exception & ex) {
if (ex.has_pos())
error(ex.line(), ex.pos(), ex.msg());
error(ex.line(), ex.pos(), ex.what());
else
error(ex.msg());
error(ex.what());
}
catch (ast_exception & ex) {
error(ex.msg());
error(ex.what());
}
catch (z3_exception & ex) {
error(ex.msg());
error(ex.what());
}
m_scanner.stop_caching();
if (m_curr_cmd)
Expand Down
2 changes: 1 addition & 1 deletion src/sat/sat_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ namespace sat {
ex_kind = ERROR_EX;
}
catch (z3_exception & ex) {
ex_msg = ex.msg();
ex_msg = ex.what();
ex_kind = DEFAULT_EX;
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/sat/sat_solver/inc_sat_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ class inc_sat_solver : public solver {
r = m_solver.check(m_asms.size(), m_asms.data());
}
catch (z3_exception& ex) {
IF_VERBOSE(1, verbose_stream() << "exception: " << ex.msg() << "\n";);
IF_VERBOSE(1, verbose_stream() << "exception: " << ex.what() << "\n";);
if (m.inc()) {
reason_set = true;
set_reason_unknown(std::string("(sat.giveup ") + ex.msg() + ')');
set_reason_unknown(std::string("(sat.giveup ") + ex.what() + ')');
}
r = l_undef;
}
Expand Down Expand Up @@ -779,9 +779,9 @@ class inc_sat_solver : public solver {
}
}
catch (tactic_exception & ex) {
IF_VERBOSE(1, verbose_stream() << "exception in tactic " << ex.msg() << "\n";);
set_reason_unknown(ex.msg());
TRACE("sat", tout << "exception: " << ex.msg() << "\n";);
IF_VERBOSE(1, verbose_stream() << "exception in tactic " << ex.what() << "\n";);
set_reason_unknown(ex.what());
TRACE("sat", tout << "exception: " << ex.what() << "\n";);
m_preprocess = nullptr;
m_bb_rewriter = nullptr;
return l_undef;
Expand Down
4 changes: 2 additions & 2 deletions src/sat/sat_solver/sat_smt_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ class sat_smt_solver : public solver {
r = m_solver.check(m_dep.m_literals);
}
catch (z3_exception& ex) {
IF_VERBOSE(1, verbose_stream() << "exception: " << ex.msg() << "\n";);
IF_VERBOSE(1, verbose_stream() << "exception: " << ex.what() << "\n";);
if (m.inc()) {
set_reason_unknown(std::string("(sat.giveup ") + ex.msg() + ')');
set_reason_unknown(std::string("(sat.giveup ") + ex.what() + ')');
return l_undef;
}
r = l_undef;
Expand Down
Loading

0 comments on commit 9206546

Please sign in to comment.