diff options
Diffstat (limited to 'console')
| -rw-r--r-- | console/console.cpp | 10 | ||||
| -rw-r--r-- | console/parse.hpp | 8 |
2 files changed, 7 insertions, 11 deletions
diff --git a/console/console.cpp b/console/console.cpp index 9a1d66f..f86dfc2 100644 --- a/console/console.cpp +++ b/console/console.cpp @@ -10,12 +10,10 @@ int main(int argc, char** argv) { try { ra::write(ra::parse(argc, argv)); } - catch (std::domain_error e) { - std::cerr << e.what() << '\n'; - return ra::INVALID_ARGUMENT; + catch (const std::system_error& e) { + std::cerr << e.what() << " (" << e.code() << ")\n"; } - catch (std::system_error e) { - std::cerr << "Error: " << e.what() << " (" << e.code() << ")\n"; - return ra::SYSTEM_ERROR; + catch (const std::exception& e) { + std::cerr << e.what() << '\n'; } } diff --git a/console/parse.hpp b/console/parse.hpp index 1cdb3fb..abdd36c 100644 --- a/console/parse.hpp +++ b/console/parse.hpp @@ -3,16 +3,12 @@ #include <iostream> #include <rawaccel.hpp> -#include <accel-error.hpp> +#include <rawaccel-error.hpp> #include "external/clipp.h" namespace rawaccel { - inline constexpr int SYSTEM_ERROR = -1; - inline constexpr int PARSE_ERROR = 1; - inline constexpr int INVALID_ARGUMENT = 2; - template<typename Accel, typename StrFirst, typename... StrRest> clipp::parameter make_accel_cmd(modifier_args& args, StrFirst&& first_flag, StrRest&&... rest) { return clipp::command(first_flag, rest...) @@ -113,6 +109,8 @@ namespace rawaccel { ); if (!clipp::parse(argc, argv, cli)) { + constexpr int PARSE_ERROR = 1; + std::cout << clipp::usage_lines(cli, "rawaccel", make_doc_fmt()); std::exit(PARSE_ERROR); } |