Skip to content

Commit 696f837

Browse files
committed
Moved exception handling [skip ci]
1 parent 3748adf commit 696f837

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

ext/or-tools/constraint.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,20 +462,24 @@ void init_constraint(Rice::Module& m) {
462462
queue.pop();
463463
}
464464

465-
callback.call("response=", r);
466-
callback.call("on_solution_callback");
465+
bool stop = false;
466+
try {
467+
callback.call("response=", r);
468+
callback.call("on_solution_callback");
469+
stop = static_cast<bool>(callback.attr_get("@stopped"));
470+
} catch (const Rice::Exception& e) {
471+
exception = e;
472+
stop = true;
473+
}
467474

468-
if (callback.attr_get("@stopped")) {
475+
if (stop) {
469476
StopSearch(&m);
470477
return Qnil;
471478
}
472479
}
473480

474481
Rice::detail::protect(rb_thread_schedule);
475482
}
476-
} catch (const Rice::Exception& e) {
477-
exception = e;
478-
StopSearch(&m);
479483
} catch (const std::exception& e) {
480484
exception = Rice::Exception(rb_eRuntimeError, e.what());
481485
StopSearch(&m);

0 commit comments

Comments
 (0)