mirror of
https://github.com/Z3Prover/z3
synced 2025-05-06 15:25:46 +00:00
overhaul of error messages. Add warning in dimacs conversion
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e622022bf9
commit
1eb8ccad59
31 changed files with 298 additions and 313 deletions
|
@ -144,9 +144,11 @@ namespace api {
|
|||
}
|
||||
}
|
||||
|
||||
void context::set_error_code(Z3_error_code err) {
|
||||
void context::set_error_code(Z3_error_code err, char const* opt_msg) {
|
||||
m_error_code = err;
|
||||
if (err != Z3_OK) {
|
||||
m_exception_msg.clear();
|
||||
if (opt_msg) m_exception_msg = opt_msg;
|
||||
invoke_error_handler(err);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +161,7 @@ namespace api {
|
|||
|
||||
void context::check_searching() {
|
||||
if (m_searching) {
|
||||
set_error_code(Z3_INVALID_USAGE); // TBD: error code could be fixed.
|
||||
set_error_code(Z3_INVALID_USAGE, "cannot use function while searching"); // TBD: error code could be fixed.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,25 +250,24 @@ namespace api {
|
|||
if (ex.has_error_code()) {
|
||||
switch(ex.error_code()) {
|
||||
case ERR_MEMOUT:
|
||||
set_error_code(Z3_MEMOUT_FAIL);
|
||||
set_error_code(Z3_MEMOUT_FAIL, nullptr);
|
||||
break;
|
||||
case ERR_PARSER:
|
||||
set_error_code(Z3_PARSER_ERROR);
|
||||
set_error_code(Z3_PARSER_ERROR, ex.msg());
|
||||
break;
|
||||
case ERR_INI_FILE:
|
||||
set_error_code(Z3_INVALID_ARG);
|
||||
set_error_code(Z3_INVALID_ARG, nullptr);
|
||||
break;
|
||||
case ERR_OPEN_FILE:
|
||||
set_error_code(Z3_FILE_ACCESS_ERROR);
|
||||
set_error_code(Z3_FILE_ACCESS_ERROR, nullptr);
|
||||
break;
|
||||
default:
|
||||
set_error_code(Z3_INTERNAL_FATAL);
|
||||
set_error_code(Z3_INTERNAL_FATAL, nullptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_exception_msg = ex.msg();
|
||||
set_error_code(Z3_EXCEPTION);
|
||||
set_error_code(Z3_EXCEPTION, ex.msg());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +302,7 @@ namespace api {
|
|||
case AST_FUNC_DECL:
|
||||
break;
|
||||
}
|
||||
set_error_code(Z3_SORT_ERROR);
|
||||
set_error_code(Z3_SORT_ERROR, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +380,7 @@ extern "C" {
|
|||
LOG_Z3_dec_ref(c, a);
|
||||
RESET_ERROR_CODE();
|
||||
if (to_ast(a)->get_ref_count() == 0) {
|
||||
SET_ERROR_CODE(Z3_DEC_REF_ERROR);
|
||||
SET_ERROR_CODE(Z3_DEC_REF_ERROR, nullptr);
|
||||
return;
|
||||
}
|
||||
mk_c(c)->m().dec_ref(to_ast(a));
|
||||
|
@ -440,10 +441,14 @@ extern "C" {
|
|||
}
|
||||
|
||||
void Z3_API Z3_set_error(Z3_context c, Z3_error_code e) {
|
||||
SET_ERROR_CODE(e);
|
||||
SET_ERROR_CODE(e, nullptr);
|
||||
}
|
||||
|
||||
static char const * _get_error_msg(Z3_context c, Z3_error_code err) {
|
||||
if (c) {
|
||||
char const* msg = mk_c(c)->get_exception_msg();
|
||||
if (msg && *msg) return msg;
|
||||
}
|
||||
switch(err) {
|
||||
case Z3_OK: return "ok";
|
||||
case Z3_SORT_ERROR: return "type error";
|
||||
|
@ -457,7 +462,7 @@ extern "C" {
|
|||
case Z3_INTERNAL_FATAL: return "internal error";
|
||||
case Z3_INVALID_USAGE: return "invalid usage";
|
||||
case Z3_DEC_REF_ERROR: return "invalid dec_ref command";
|
||||
case Z3_EXCEPTION: return c == nullptr ? "Z3 exception" : mk_c(c)->get_exception_msg();
|
||||
case Z3_EXCEPTION: return "Z3 exception";
|
||||
default: return "unknown";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue