diff --git a/exaudfclient/BUILD b/exaudfclient/BUILD index a0c3665c..656ed774 100644 --- a/exaudfclient/BUILD +++ b/exaudfclient/BUILD @@ -77,7 +77,7 @@ cc_binary( name = "exaudfclient_bin", srcs = ["exaudfclient.cc", "//base:load_dynamic"], linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace - deps = ["//base/exaudflib:header", "//base:debug_message_h"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+ + deps = ["//base/exaudflib:header", "//base/utils:utils"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+ ["//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory"], defines = VM_ENABLED_DEFINES, data = ["//base:libexaudflib_complete.so"] @@ -100,7 +100,7 @@ cc_binary( name = "exaudfclient_static_bin", srcs = ["exaudfclient.cc", "//base:load_dynamic"], linkopts = ["-ldl"], # needed for dynamicly loading libexaudflib_complete.so into another linker namespace - deps = ["//base/exaudflib:header", "//base:debug_message_h"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+ + deps = ["//base/exaudflib:header", "//base/utils:utils"]+VM_ENABLED_DEPS+VM_PYTHON3_DEPS+ ["//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory"] + [ "@zmq//:zmq", "@protobuf//:protobuf"], defines = VM_ENABLED_DEFINES, diff --git a/exaudfclient/base/BUILD b/exaudfclient/base/BUILD index 687ba0d2..357c34da 100644 --- a/exaudfclient/base/BUILD +++ b/exaudfclient/base/BUILD @@ -6,19 +6,13 @@ exports_files(["filter_swig_code.py", "build_integrated.py", load("//:variables.bzl", "VM_ENABLED_DEFINES") -cc_library( - name = "debug_message_h", - hdrs = [ - "debug_message.h" - ], -) cc_library( name = "load_dynamic", srcs = [ "load_dynamic.cc" ], - deps = ["//base/exaudflib:header", "//base:debug_message_h", "//base/exaudflib:exaudflib-deps"], + deps = ["//base/exaudflib:header", "//base/utils:utils", "//base/exaudflib:exaudflib-deps"], defines = VM_ENABLED_DEFINES, ) diff --git a/exaudfclient/base/benchmark_container/BUILD b/exaudfclient/base/benchmark_container/BUILD index 33b5be8c..9c7c0ba8 100644 --- a/exaudfclient/base/benchmark_container/BUILD +++ b/exaudfclient/base/benchmark_container/BUILD @@ -4,5 +4,5 @@ cc_library( name = "benchmark_container", srcs = ["benchmark_container.cc","benchmark_container.h"], hdrs = ["benchmark_container.h"], - deps = ["//base/exaudflib:exaudflib-deps","//base/exaudflib:header", "//base:debug_message_h"]+["//base/script_options_parser:scriptoptionlines"] + deps = ["//base/exaudflib:exaudflib-deps","//base/exaudflib:header", "//base/utils:utils"]+["//base/script_options_parser:scriptoptionlines"] ) \ No newline at end of file diff --git a/exaudfclient/base/benchmark_container/benchmark_container.cc b/exaudfclient/base/benchmark_container/benchmark_container.cc index 3efa97cd..057bc375 100644 --- a/exaudfclient/base/benchmark_container/benchmark_container.cc +++ b/exaudfclient/base/benchmark_container/benchmark_container.cc @@ -2,7 +2,7 @@ #define ENABLE_BENCHMARK_VM #endif -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include "benchmark_container.h" #include #include diff --git a/exaudfclient/base/exaudflib/BUILD b/exaudfclient/base/exaudflib/BUILD index ed07bfde..4cc20aac 100644 --- a/exaudfclient/base/exaudflib/BUILD +++ b/exaudfclient/base/exaudflib/BUILD @@ -94,5 +94,5 @@ cc_library( "impl/swig/swig_general_iterator.h", "impl/swig/swig_general_iterator.cc"], defines = VM_ENABLED_DEFINES, linkstatic = False, # Needs to be false, because otherwise we might get missing symbols when loading exaudflib_complete.so - deps = [":exaudflib-deps", ":zmqcontainer", "@zmq//:zmq", ":header", "//base:debug_message_h"], + deps = [":exaudflib-deps", ":zmqcontainer", "@zmq//:zmq", ":header", "//base/utils:utils"], ) diff --git a/exaudfclient/base/exaudflib/impl/check.cc b/exaudfclient/base/exaudflib/impl/check.cc index 44ca9345..b39e8510 100644 --- a/exaudfclient/base/exaudflib/impl/check.cc +++ b/exaudfclient/base/exaudflib/impl/check.cc @@ -6,7 +6,7 @@ #include -#include "base/debug_message.h" +#include "base/utils/debug_message.h" namespace exaudflib { namespace check { diff --git a/exaudfclient/base/exaudflib/impl/exaudflib_main.cc b/exaudfclient/base/exaudflib/impl/exaudflib_main.cc index cd74f240..2e0943a4 100644 --- a/exaudfclient/base/exaudflib/impl/exaudflib_main.cc +++ b/exaudfclient/base/exaudflib/impl/exaudflib_main.cc @@ -10,7 +10,7 @@ #include #include -#include "base/debug_message.h" +#include "base/utils/debug_message.h" // swig lib #include diff --git a/exaudfclient/base/exaudflib/impl/socket_high_level.cc b/exaudfclient/base/exaudflib/impl/socket_high_level.cc index 64721cef..3a4d4d8d 100644 --- a/exaudfclient/base/exaudflib/impl/socket_high_level.cc +++ b/exaudfclient/base/exaudflib/impl/socket_high_level.cc @@ -7,7 +7,7 @@ #include "base/exaudflib/swig/swig_common.h" #include "base/exaudflib/vm/swig_vm.h" #include -#include "base/debug_message.h" +#include "base/utils/debug_message.h" namespace exaudflib { namespace socket_high_level { diff --git a/exaudfclient/base/exaudflib/impl/socket_low_level.cc b/exaudfclient/base/exaudflib/impl/socket_low_level.cc index 5bd14a30..74e2de8b 100644 --- a/exaudfclient/base/exaudflib/impl/socket_low_level.cc +++ b/exaudfclient/base/exaudflib/impl/socket_low_level.cc @@ -1,6 +1,6 @@ #include "base/exaudflib/impl/socket_low_level.h" #include "base/exaudflib/impl/check.h" -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include #include #include diff --git a/exaudfclient/base/javacontainer/BUILD b/exaudfclient/base/javacontainer/BUILD index c42f4cff..fa42cd31 100644 --- a/exaudfclient/base/javacontainer/BUILD +++ b/exaudfclient/base/javacontainer/BUILD @@ -109,7 +109,7 @@ cc_library( srcs = [":javacontainer.cc", ":javacontainer.h", ":javacontainer_impl.cc", ":javacontainer_impl.h", ":dummy"], hdrs = [":filter_swig_code_exascript_java_h", "exascript_java_jni_decl.h"], deps = ["@ssl//:ssl","@java//:java", ":exascript_java", "//base/exaudflib:header", - "//base:debug_message_h","//base/javacontainer/script_options:java_script_option_lines", + "//base/utils:utils","//base/javacontainer/script_options:java_script_option_lines", "//base/swig_factory:swig_factory_if"], # copts= ["-O0","-fno-lto"], alwayslink=True, diff --git a/exaudfclient/base/javacontainer/javacontainer_impl.cc b/exaudfclient/base/javacontainer/javacontainer_impl.cc index ec857723..96aa0898 100644 --- a/exaudfclient/base/javacontainer/javacontainer_impl.cc +++ b/exaudfclient/base/javacontainer/javacontainer_impl.cc @@ -8,7 +8,7 @@ #include "exascript_java_jni_decl.h" -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include "base/javacontainer/javacontainer.h" #include "base/javacontainer/javacontainer_impl.h" #include "base/javacontainer/script_options/extractor.h" @@ -35,21 +35,18 @@ JavaVMImpl::JavaVMImpl(bool checkOnly, bool noJNI, SwigFactory& swigFactory) m_exaJavaPath = "/exaudf/base/javacontainer"; // TODO hardcoded path JavaScriptOptions::ScriptOptionLinesParserLegacy scriptOptionsParser; - try { - JavaScriptOptions::Extractor extractor(scriptOptionsParser, swigFactory); - DBG_FUNC_CALL(cerr,extractor.extract(m_scriptCode)); // To be called before scripts are imported. Otherwise, the script classname from an imported script could be used + JavaScriptOptions::Extractor extractor(scriptOptionsParser, swigFactory); - DBG_FUNC_CALL(cerr,setClasspath()); + DBG_FUNC_CALL(cerr,extractor.extract(m_scriptCode)); // To be called before scripts are imported. Otherwise, the script classname from an imported script could be used - m_jvmOptions = std::move(extractor.moveJvmOptions()); + DBG_FUNC_CALL(cerr,setClasspath()); - for (set::iterator it = extractor.getJarPaths().begin(); it != extractor.getJarPaths().end(); - ++it) { - addJarToClasspath(*it); - } - } catch(const std::runtime_error& ex) { - throwException(ex); + m_jvmOptions = std::move(extractor.moveJvmOptions()); + + for (set::iterator it = extractor.getJarPaths().begin(); it != extractor.getJarPaths().end(); + ++it) { + addJarToClasspath(*it); } m_needsCompilation = checkNeedsCompilation(); diff --git a/exaudfclient/base/javacontainer/script_options/BUILD b/exaudfclient/base/javacontainer/script_options/BUILD index e453ec0b..585f8a31 100644 --- a/exaudfclient/base/javacontainer/script_options/BUILD +++ b/exaudfclient/base/javacontainer/script_options/BUILD @@ -6,6 +6,7 @@ cc_library( hdrs = [":extractor.h", ":parser_legacy.h"], srcs = [":parser.h", ":converter.h", ":converter.cc", ":parser_legacy.cc", ":extractor.cc", ":keywords.h", ":checksum.h", ":checksum.cc"], - deps = ["//base/script_options_parser/legacy:script_option_lines_parser_legacy", "//base:debug_message_h", - "//base/exaudflib:header", "//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory_if"], + deps = ["//base/script_options_parser/legacy:script_option_lines_parser_legacy", "//base/utils:utils", + "//base/exaudflib:header", "//base/exaudflib:exaudflib-deps", "//base/swig_factory:swig_factory_if", + "//base/script_options_parser:exception"], ) diff --git a/exaudfclient/base/javacontainer/script_options/converter.h b/exaudfclient/base/javacontainer/script_options/converter.h index eda178db..53a07029 100644 --- a/exaudfclient/base/javacontainer/script_options/converter.h +++ b/exaudfclient/base/javacontainer/script_options/converter.h @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/exaudfclient/base/javacontainer/script_options/extractor.cc b/exaudfclient/base/javacontainer/script_options/extractor.cc index 5f6bb0cf..ed33388b 100644 --- a/exaudfclient/base/javacontainer/script_options/extractor.cc +++ b/exaudfclient/base/javacontainer/script_options/extractor.cc @@ -1,7 +1,7 @@ #include "base/javacontainer/script_options/extractor.h" #include "base/javacontainer/script_options/parser.h" -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include #define EXTR_DBG_FUNC_CALL(f) DBG_FUNC_CALL(std::cerr, f) diff --git a/exaudfclient/base/javacontainer/script_options/extractor.h b/exaudfclient/base/javacontainer/script_options/extractor.h index ab4055ca..d69ae354 100644 --- a/exaudfclient/base/javacontainer/script_options/extractor.h +++ b/exaudfclient/base/javacontainer/script_options/extractor.h @@ -3,7 +3,6 @@ #include #include -#include #include diff --git a/exaudfclient/base/javacontainer/script_options/parser_legacy.cc b/exaudfclient/base/javacontainer/script_options/parser_legacy.cc index c32dfec7..4462e73b 100644 --- a/exaudfclient/base/javacontainer/script_options/parser_legacy.cc +++ b/exaudfclient/base/javacontainer/script_options/parser_legacy.cc @@ -3,10 +3,10 @@ #include "base/script_options_parser/legacy/script_option_lines.h" #include "base/exaudflib/swig/swig_meta_data.h" #include "base/swig_factory/swig_factory.h" +#include "base/utils/exceptions.h" +#include "base/script_options_parser/exception.h" #include -#include - namespace SWIGVMContainers { @@ -106,8 +106,8 @@ void ScriptOptionLinesParserLegacy::extractImportScripts(SwigFactory & swigFacto try { parseForSingleOption(m_keywords.importKeyword(), [&](const std::string& value, size_t pos){scriptPos = pos; newScript = value;}); - } catch (const std::runtime_error & ex) { - throw std::runtime_error(std::string("F-UDF-CL-SL-JAVA-1614 ") + ex.what()); + } catch (const ExecutionGraph::OptionParserException & ex) { + Utils::rethrow(ex, "F-UDF-CL-SL-JAVA-1614"); } if (!newScript.empty()) { if (!metaData) { @@ -135,8 +135,8 @@ void ScriptOptionLinesParserLegacy::parseForScriptClass(std::function #include "base/exaudflib/swig/swig_common.h" -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include diff --git a/exaudfclient/base/python/pythoncontainer.cc b/exaudfclient/base/python/pythoncontainer.cc index cc258113..a52b29f5 100644 --- a/exaudfclient/base/python/pythoncontainer.cc +++ b/exaudfclient/base/python/pythoncontainer.cc @@ -9,7 +9,7 @@ #include #include "exascript_python_int.h" #include "exascript_python.h" -#include "base/debug_message.h" +#include "base/utils/debug_message.h" #include "base/exaudflib/swig/script_data_transfer_objects.h" diff --git a/exaudfclient/base/script_options_parser/BUILD b/exaudfclient/base/script_options_parser/BUILD index ffd0fb0c..03bb142f 100644 --- a/exaudfclient/base/script_options_parser/BUILD +++ b/exaudfclient/base/script_options_parser/BUILD @@ -1 +1,6 @@ package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "exception", + hdrs = ["exception.h"] +) diff --git a/exaudfclient/base/script_options_parser/ctpg/BUILD b/exaudfclient/base/script_options_parser/ctpg/BUILD index c2da0d62..cdb9ee34 100644 --- a/exaudfclient/base/script_options_parser/ctpg/BUILD +++ b/exaudfclient/base/script_options_parser/ctpg/BUILD @@ -4,5 +4,6 @@ cc_library( name = "script_option_lines_parser_ctpg", hdrs = ["script_option_lines_ctpg.h"], srcs = ["script_option_lines_ctpg.cc","ctpg.hpp"], + deps = ["//base/script_options_parser:exception"], copts= ["-fno-lto"], ) diff --git a/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.cc b/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.cc index a338be27..9baa6c67 100644 --- a/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.cc +++ b/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.cc @@ -3,6 +3,7 @@ #include #include #include +#include "base/script_options_parser/exception.h" using namespace exaudf_ctpg; using namespace exaudf_ctpg::ftors; @@ -147,7 +148,7 @@ void parse(std::string&& code, options_type& result) { { std::stringstream ss; ss << "Error parsing script options: " << error_buffer.str(); - throw std::runtime_error(ss.str()); + throw OptionParserException(ss.str()); } } diff --git a/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.h b/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.h index 23699a6b..21c29034 100644 --- a/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.h +++ b/exaudfclient/base/script_options_parser/ctpg/script_option_lines_ctpg.h @@ -2,7 +2,6 @@ #define SCRIPTOPTIONLINESCTPG_H #include -#include #include #include #include diff --git a/exaudfclient/base/script_options_parser/ctpg/test/script_option_lines_test.cpp b/exaudfclient/base/script_options_parser/ctpg/test/script_option_lines_test.cpp index 630778e5..11f04b6c 100644 --- a/exaudfclient/base/script_options_parser/ctpg/test/script_option_lines_test.cpp +++ b/exaudfclient/base/script_options_parser/ctpg/test/script_option_lines_test.cpp @@ -3,8 +3,10 @@ #include #include #include +#include "base/script_options_parser/exception.h" +using namespace ExecutionGraph; using namespace ExecutionGraph::OptionsLineParser::CTPG; using ::testing::MatchesRegex; @@ -75,13 +77,13 @@ TEST(ScriptOptionLinesTest, need_option_termination_character) { { parseOptions(code, result); } - catch( const std::runtime_error& e ) + catch( const OptionParserException& e ) { // and this tests that it has the correct message EXPECT_STREQ( e.what(), "Error parsing script options: [1:17] PARSE: Syntax error: Unexpected ''\n"); throw; } - }, std::runtime_error ); + }, OptionParserException ); } TEST(ScriptOptionLinesTest, finds_the_two_options_same_key) { @@ -131,12 +133,12 @@ TEST_P(ScriptOptionLinesInvalidOptionTest, value_is_mandatory) { { parseOptions(code, result); } - catch( const std::runtime_error& e ) + catch( const OptionParserException& e ) { EXPECT_THAT( e.what(), MatchesRegex("^Error parsing script options.*PARSE: Syntax error: Unexpected.*$")); throw; } - }, std::runtime_error ); + }, OptionParserException ); } const std::vector invalid_options = {"%some_option ;", "%some_option \n", "\n%some_option\n;", "%some_option\nvalue;"}; diff --git a/exaudfclient/base/script_options_parser/exception.h b/exaudfclient/base/script_options_parser/exception.h new file mode 100644 index 00000000..ff535c7f --- /dev/null +++ b/exaudfclient/base/script_options_parser/exception.h @@ -0,0 +1,17 @@ +#ifndef SCRIPTOPTIONLINESEXCEPTION_H +#define SCRIPTOPTIONLINESEXCEPTION_H + +#include + + +namespace ExecutionGraph +{ + +class OptionParserException : public std::runtime_error { + using std::runtime_error::runtime_error; +}; + + +} // namespace ExecutionGraph + +#endif // SCRIPTOPTIONLINESEXCEPTION_H \ No newline at end of file diff --git a/exaudfclient/base/script_options_parser/legacy/BUILD b/exaudfclient/base/script_options_parser/legacy/BUILD index 30bdb8fb..d4aa0421 100644 --- a/exaudfclient/base/script_options_parser/legacy/BUILD +++ b/exaudfclient/base/script_options_parser/legacy/BUILD @@ -4,5 +4,6 @@ cc_library( name = "script_option_lines_parser_legacy", hdrs = ["script_option_lines.h"], srcs = ["script_option_lines.cc"], + deps = ["//base/script_options_parser:exception"], copts= ["-fno-lto"], ) diff --git a/exaudfclient/base/script_options_parser/legacy/script_option_lines.cc b/exaudfclient/base/script_options_parser/legacy/script_option_lines.cc index 180f896f..b0b7e487 100644 --- a/exaudfclient/base/script_options_parser/legacy/script_option_lines.cc +++ b/exaudfclient/base/script_options_parser/legacy/script_option_lines.cc @@ -1,6 +1,7 @@ #include "script_option_lines.h" #include #include +#include "base/script_options_parser/exception.h" @@ -62,27 +63,27 @@ std::string extractOptionLine(std::string& code, const std::string option, const if (firstPos == std::string::npos) { std::stringstream ss; ss << "No values found for " << option << " statement"; - throw std::runtime_error(ss.str().c_str()); + throw OptionParserException(ss.str().c_str()); } // Find the end of line. size_t lastPos = code.find_first_of(lineEnd + "\r\n", firstPos); if (lastPos == std::string::npos || code.compare(lastPos, lineEnd.length(), lineEnd) != 0) { std::stringstream ss; ss << "End of " << option << " statement not found"; - throw std::runtime_error(ss.str().c_str()); + throw OptionParserException(ss.str().c_str()); } // If no values were found if (firstPos >= lastPos) { std::stringstream ss; ss << "No values found for " << option << " statement"; - throw std::runtime_error(ss.str().c_str()); + throw OptionParserException(ss.str().c_str()); } // If no values were found size_t optionsEnd = code.find_last_not_of(whitespace, lastPos - 1); if (optionsEnd == std::string::npos || optionsEnd < firstPos) { std::stringstream ss; ss << "No values found for " << option << " statement"; - throw std::runtime_error(ss.str().c_str()); + throw OptionParserException(ss.str().c_str()); } result = code.substr(firstPos, optionsEnd - firstPos + 1); code.erase(startPos, lastPos - startPos + 1); diff --git a/exaudfclient/base/script_options_parser/legacy/script_option_lines.h b/exaudfclient/base/script_options_parser/legacy/script_option_lines.h index b16efe54..00670a71 100644 --- a/exaudfclient/base/script_options_parser/legacy/script_option_lines.h +++ b/exaudfclient/base/script_options_parser/legacy/script_option_lines.h @@ -2,11 +2,11 @@ #define SCRIPTOPTIONLINES_H #include -#include namespace ExecutionGraph { + /*! * \brief extractOptionLine Extracts syntactically valid option lines of form %