X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/d625e80d62fc8b98c18a95c65e6fa329b7fcc85b..9977f098136de2dd74a62de2fc535cbdfafcda1f:/projects/sgconf/main.cpp diff --git a/projects/sgconf/main.cpp b/projects/sgconf/main.cpp index a1c8df8f..c1fc4c3e 100644 --- a/projects/sgconf/main.cpp +++ b/projects/sgconf/main.cpp @@ -178,6 +178,10 @@ class CONFIG_ACTION : public ACTION PARSER_STATE CONFIG_ACTION::Parse(int argc, char ** argv) { +if (argc == 0 || + argv == NULL || + *argv == NULL) + throw ERROR("Missing argument."); char * pos = strchr(*argv, '@'); if (pos != NULL) { @@ -1214,7 +1218,18 @@ blocks.Add("Connection options") .Add("w", "userpass", SGCONF::MakeParamAction(config.userPass, ""), "\tpassword for the administrative login") .Add("a", "address", SGCONF::MakeParamAction(config, ""), "connection params as a single string in format: :@:"); -SGCONF::PARSER_STATE state(blocks.Parse(--argc, ++argv)); // Skipping self name + +SGCONF::PARSER_STATE state(false, argc, argv); + +try +{ +state = blocks.Parse(--argc, ++argv); // Skipping self name +} +catch (const SGCONF::OPTION::ERROR& ex) +{ +std::cerr << ex.what() << "\n"; +return -1; +} if (state.stop) return 0;