diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-25 21:05:44 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-25 21:05:44 (GMT) |
commit | e3767be4f9c5874d9c996200f2e9705ce31a5976 (patch) | |
tree | be3d06f550286e23eeb3252277c1a2b7d12554ef /src/uscxml/Interpreter.cpp | |
parent | 758bda908ded461c9d34d274a18454ffba4b7450 (diff) | |
download | uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.zip uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.tar.gz uscxml-e3767be4f9c5874d9c996200f2e9705ce31a5976.tar.bz2 |
Work on bindings
- Introduced exceptions into C# and Java
- Moved binding examples to /embedding
- Interpreter will now throw exceptions, beware!
Diffstat (limited to 'src/uscxml/Interpreter.cpp')
-rw-r--r-- | src/uscxml/Interpreter.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 4ffa92c..9770387 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -82,7 +82,8 @@ #define VALID_FROM_IDLE(newState) ( \ newState == InterpreterState::USCXML_DESTROYED || \ - newState == InterpreterState::USCXML_MICROSTEPPED \ + newState == InterpreterState::USCXML_MICROSTEPPED || \ + newState == InterpreterState::USCXML_MACROSTEPPED \ ) #define VALID_FROM_FINISHED(newState) ( \ @@ -90,6 +91,12 @@ newState == InterpreterState::USCXML_INSTANTIATED \ ) +#define THROW_ERROR_PLATFORM(msg) \ + Event e; \ + e.name = "error.platform"; \ + e.data.compound["cause"] = Data(msg, Data::VERBATIM); \ + throw e; \ + /// macro to catch exceptions in executeContent #define CATCH_AND_DISTRIBUTE(msg) \ @@ -378,8 +385,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { URL absUrl(uri); if (!absUrl.isAbsolute()) { if (!absUrl.toAbsoluteCwd()) { - LOG(ERROR) << "Given URL is not absolute or does not have file schema"; - return Interpreter(); + THROW_ERROR_PLATFORM("Given URL is not absolute or does not have file schema"); } } @@ -401,8 +407,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { std::stringstream ss; ss << absUrl; if (absUrl.downloadFailed()) { - LOG(ERROR) << "Downloading SCXML document from " << absUrl << " failed"; - return interpreter; + THROW_ERROR_PLATFORM("Downloading SCXML document from " + absUrl.asString() + " failed"); } interpreter = fromXML(ss.str()); } @@ -412,7 +417,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) { interpreter._impl->_baseURI = URL::asBaseURL(absUrl); interpreter._impl->_sourceURI = absUrl; } else { - LOG(ERROR) << "Cannot create interpreter from URI '" << absUrl.asString() << "'"; + THROW_ERROR_PLATFORM("Cannot create interpreter from URI " + absUrl.asString() + "'"); } return interpreter; } @@ -439,8 +444,12 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& interpreterImpl->setNameSpaceInfo(parser.nameSpace); interpreterImpl->_document = parser.getDocument(); } else { -// assert(parser.errorsReported()); - interpreterImpl->setInterpreterState(InterpreterState::USCXML_FAULTED, parser.errors()); + if (parser.errorsReported()) { + THROW_ERROR_PLATFORM(parser.errors()) + } else { + THROW_ERROR_PLATFORM("Failed to create interpreter"); +// interpreterImpl->setInterpreterState(InterpreterState::USCXML_FAULTED, parser.errors()); + } } return interpreter; } |