diff --git a/__jet.cpp b/__jet.cpp index da46c16..106c27a 100644 --- a/__jet.cpp +++ b/__jet.cpp @@ -1,10 +1,21 @@ #include "__jet.h" +#include "Exception.h" #include namespace jet { __jet::__jet(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) { - processContainer(container); + + try { + processContainer(container); + } + catch(coreutils::Exception e) { + std::cout << container.parsed() << std::endl; + std::cout << "***** " << e.text << std::endl; + std::cout << container.unparsed() << std::endl; + throw e; + } + } } diff --git a/__mysql.cpp b/__mysql.cpp index 13aa5a7..d867893 100644 --- a/__mysql.cpp +++ b/__mysql.cpp @@ -21,7 +21,10 @@ namespace jet { mysql = mysql_init(NULL); mysql = mysql_real_connect(mysql, variables["host"].c_str(), variables["user"].c_str(), variables["password"].c_str(), variables["database"].c_str(), 0, NULL, 0); - + + if(!mysql) + throw coreutils::Exception("database and host parameters are not valid."); + std::cout << "mysql: " << mysql << std::endl; processContainer(container); diff --git a/compile b/compile index 4b6777c..197152f 100755 --- a/compile +++ b/compile @@ -17,8 +17,8 @@ do done wait -echo -n "Building executable testjet..." -g++ -g -o testjet $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient +echo -n "Building executable jet-2.0..." +g++ -g -o jet-2.0 $list -std=c++23 -L../CoreUtils -lCoreUtils -lmysqlclient if [ $? = '0' ] then echo "OK" diff --git a/jet-2.0 b/jet-2.0 new file mode 100755 index 0000000..0c45f83 Binary files /dev/null and b/jet-2.0 differ diff --git a/jet-2.0.cpp b/jet-2.0.cpp new file mode 100644 index 0000000..9f81aa7 --- /dev/null +++ b/jet-2.0.cpp @@ -0,0 +1,26 @@ +#include +#include +#include "File.h" +#include "Global.h" +#include "Exception.h" +#include "__jet.h" + +int main(int argc, char **argv) { + + coreutils::File script(argv[1]); + script.read(); + coreutils::ZString data = script.asZString(); + data.goeol(); + + try { + jet::Global global; + coreutils::MString out; + jet::__jet *jet = new jet::__jet(data, out, global); + delete jet; + std::cout << out; + } + catch(coreutils::Exception e) { + std::cout << "Error caught: " << e.text << std::endl; + } + +} diff --git a/testjet.cpp b/testjet.cpp deleted file mode 100644 index 1bdec03..0000000 --- a/testjet.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include -#include "Global.h" -#include "Exception.h" -#include "__jet.h" - -int main(int argc, char **argv) { - - coreutils::ZString data("\n" - " This is a comment and should not show up in the output.\n" - " \n" - " $[nonexistant]\n" - " \n" - " select * from testdata\n" - " $[1.text]\n" - " $[1.value]\n" - " \n" - " \n" - " \n" - " \n" - " theexpr=($[theexpr])\n" - " theexpr2($[theexpr2])\n" - " \n" - " this is the value store in #[name].\n" - " this is the value store in #[name].\n" - " another container value\n" - " >>>$[noeval]<<<\n" - " >>>$[thename]<<<\n" - " \n" - " \n" - " \n" - " $[test$[ix$[ix1]]$[iz]]\n" - " \n" - " 789\n" - " \n" - " 123\n" - " \n" - " 456\n" - " \n" - " \n" - " \n" - " -->#[ix]<--\n" - " \n" - " \n" - " $[lsi]\n" - " \n" - " $[filex]\n" - " \n" - "\n"); - - std::cout << "---------\n" << data << "----------\n" << std::endl; - - try { - jet::Global global; - coreutils::MString out; - jet::__jet *jet = new jet::__jet(data, out, global); - delete jet; - std::cout << ">>-------" << std::endl << out << "<<------" << std::endl; - // global.dump(); - } - catch(coreutils::Exception e) { - std::cout << "Error caught: " << e.text << std::endl; - } - -} diff --git a/testjet.jet b/testjet.jet new file mode 100755 index 0000000..05b08c0 --- /dev/null +++ b/testjet.jet @@ -0,0 +1,42 @@ +#!./jet-2.0 + + This is a comment and should not show up in the output. + + $[nonexistant] + + select * from testdata + $[1.text] + $[1.value] + + + + + theexpr=($[theexpr]) + theexpr2($[theexpr2]) + + this is the value store in #[name]. + this is the value store in #[name]. + another container value + >>>$[noeval]<<< + >>>$[thename]<<< + + + + $[test$[ix$[ix1]]$[iz]] + + 789 + + 123 + + 456 + + + + -->#[ix]<-- + + + $[lsi] + + $[filex] + +