
Module: ppl/ppl Branch: master Commit: 0f40cc8d92d033ab5c78cdd2d4661f395603e8b5 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=0f40cc8d92d03...
Author: Patricia Hill p.m.hill@leeds.ac.uk Date: Sat Mar 20 22:00:34 2010 +0000
Added further needed code for handling logic_error exception.
---
interfaces/Prolog/ppl_prolog_common.cc | 10 ++++++++++ interfaces/Prolog/ppl_prolog_common.defs.hh | 6 +++--- 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/interfaces/Prolog/ppl_prolog_common.cc b/interfaces/Prolog/ppl_prolog_common.cc index 0c1b4a2..4921bf9 100644 --- a/interfaces/Prolog/ppl_prolog_common.cc +++ b/interfaces/Prolog/ppl_prolog_common.cc @@ -161,6 +161,7 @@ Prolog_atom a_ppl_invalid_argument; Prolog_atom a_ppl_overflow_error; Prolog_atom a_ppl_domain_error; Prolog_atom a_ppl_length_error; +Prolog_atom a_ppl_logic_error; Prolog_atom a_ppl_representation_error; Prolog_atom a_expected; Prolog_atom a_found; @@ -245,6 +246,7 @@ const Prolog_Interface_Atom prolog_interface_atoms[] = { { &a_ppl_overflow_error, "ppl_overflow_error" }, { &a_ppl_domain_error, "ppl_domain_error" }, { &a_ppl_length_error, "ppl_length_error" }, + { &a_ppl_logic_error, "ppl_logic_error" }, { &a_ppl_representation_error, "ppl_representation_error" }, { &a_expected, "expected" }, { &a_found, "found" }, @@ -583,6 +585,14 @@ handle_exception(const std::length_error& e) { }
void +handle_exception(const std::logic_error& e) { + Prolog_term_ref et = Prolog_new_term_ref(); + Prolog_construct_compound(et, a_ppl_logic_error, + Prolog_atom_term_from_string(e.what())); + Prolog_raise_exception(et); +} + +void handle_exception(const std::bad_alloc&) { Prolog_term_ref et = Prolog_new_term_ref(); Prolog_put_atom(et, out_of_memory_exception_atom); diff --git a/interfaces/Prolog/ppl_prolog_common.defs.hh b/interfaces/Prolog/ppl_prolog_common.defs.hh index ce3fb55..c674f50 100644 --- a/interfaces/Prolog/ppl_prolog_common.defs.hh +++ b/interfaces/Prolog/ppl_prolog_common.defs.hh @@ -510,13 +510,13 @@ handle_exception(const deterministic_timeout_exception&); catch(const std::length_error& e) { \ handle_exception(e); \ } \ - catch (const std::bad_alloc& e) { \ + catch (const std::logic_error& e) { \ handle_exception(e); \ } \ - catch (const std::exception& e) { \ + catch (const std::bad_alloc& e) { \ handle_exception(e); \ } \ - catch (const std::logic_error& e) { \ + catch (const std::exception& e) { \ handle_exception(e); \ } \ catch (...) { \