From 59cb1ace343f74af41fae55933be48d1b3995780 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Fri, 17 May 2013 10:19:54 -0400 Subject: [PATCH] Better error on invalid logic strings. Thanks to David Cok for reporting this issue. Conflicts: library_versions --- src/smt/smt_engine.cpp | 16 ++++++++-------- src/smt/smt_engine.h | 4 ++-- src/theory/logic_info.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 284f39d54..3ee6b1d74 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -791,21 +791,21 @@ SmtEngine::~SmtEngine() throw() { void SmtEngine::setLogic(const LogicInfo& logic) throw(ModalException) { SmtScope smts(this); - d_logic = logic; setLogicInternal(); } -void SmtEngine::setLogic(const std::string& s) throw(ModalException) { +void SmtEngine::setLogic(const std::string& s) throw(ModalException, LogicException) { SmtScope smts(this); - - setLogic(LogicInfo(s)); + try { + setLogic(LogicInfo(s)); + } catch(IllegalArgumentException& e) { + throw LogicException(e.what()); + } } -void SmtEngine::setLogic(const char* logic) throw(ModalException){ - SmtScope smts(this); - - setLogic(LogicInfo(string(logic))); +void SmtEngine::setLogic(const char* logic) throw(ModalException, LogicException) { + setLogic(string(logic)); } LogicInfo SmtEngine::getLogicInfo() const { diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h index a22e34c21..8266bb1ed 100644 --- a/src/smt/smt_engine.h +++ b/src/smt/smt_engine.h @@ -350,12 +350,12 @@ public: /** * Set the logic of the script. */ - void setLogic(const std::string& logic) throw(ModalException); + void setLogic(const std::string& logic) throw(ModalException, LogicException); /** * Set the logic of the script. */ - void setLogic(const char* logic) throw(ModalException); + void setLogic(const char* logic) throw(ModalException, LogicException); /** * Set the logic of the script. diff --git a/src/theory/logic_info.cpp b/src/theory/logic_info.cpp index dc9de8662..cbd0b510e 100644 --- a/src/theory/logic_info.cpp +++ b/src/theory/logic_info.cpp @@ -241,7 +241,12 @@ void LogicInfo::setLogicString(std::string logicString) throw(IllegalArgumentExc } if(*p != '\0') { stringstream err; - err << "LogicInfo::setLogicString(): junk (\"" << p << "\") at end of logic string: " << logicString; + err << "LogicInfo::setLogicString(): "; + if(p == logicString) { + err << "cannot parse logic string: " << logicString; + } else { + err << "junk (\"" << p << "\") at end of logic string: " << logicString; + } IllegalArgument(logicString, err.str().c_str()); } -- 2.30.2