mirror of
https://github.com/Z3Prover/z3
synced 2025-04-22 16:45:31 +00:00
Merge pull request #1969 from Bronsa/master
Catch and print exceptions in Z3_mk_config
This commit is contained in:
commit
c5f280ae6e
3 changed files with 37 additions and 4 deletions
|
@ -68,10 +68,17 @@ extern "C" {
|
|||
}
|
||||
|
||||
Z3_config Z3_API Z3_mk_config(void) {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_mk_config();
|
||||
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
|
||||
RETURN_Z3(r);
|
||||
try {
|
||||
memory::initialize(UINT_MAX);
|
||||
LOG_Z3_mk_config();
|
||||
Z3_config r = reinterpret_cast<Z3_config>(alloc(context_params));
|
||||
RETURN_Z3(r);
|
||||
} catch (z3_exception & ex) {
|
||||
// The error handler is only available for contexts
|
||||
// Just throw a warning.
|
||||
warning_msg("%s", ex.msg());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Z3_API Z3_del_config(Z3_config c) {
|
||||
|
|
|
@ -448,3 +448,21 @@ CAMLprim value DLL_PUBLIC n_set_internal_error_handler(value ctx_v)
|
|||
Z3_set_error_handler(ctx_p->ctx, MLErrorHandler);
|
||||
CAMLreturn(Val_unit);
|
||||
}
|
||||
|
||||
CAMLprim DLL_PUBLIC value n_mk_config() {
|
||||
CAMLparam0();
|
||||
CAMLlocal1(result);
|
||||
Z3_config z3rv;
|
||||
|
||||
/* invoke Z3 function */
|
||||
z3rv = Z3_mk_config();
|
||||
|
||||
if (z3rv == NULL) {
|
||||
caml_raise_with_string(*caml_named_value("Z3EXCEPTION"), "internal error");
|
||||
}
|
||||
|
||||
/* construct simple return value */
|
||||
result = caml_alloc_custom(&default_custom_ops, sizeof(Z3_config), 0, 1); *(Z3_config*)Data_custom_val(result) = z3rv;
|
||||
/* cleanup and return */
|
||||
CAMLreturn(result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue