in main.cpp [13:53]
int exec(std::string&& str, VS&& vs)
{
namespace inference = poac::core::infer;
namespace exception = poac::core::exception;
namespace cli = poac::io::cli;
using namespace std::string_literals;
// TODO: 広い空間でcatchするのは危険.Result typeを使用したい
try {
return std::stoi(inference::apply("exec"s, str, std::move(vs)));
}
catch (const exception::invalid_first_arg& e) {
std::cerr << cli::to_red("ERROR: ") << e.what() << std::endl << std::endl;
inference::apply("exec"s, "--help"s, VS());
return EXIT_FAILURE;
}
catch (const exception::invalid_second_arg& e) {
inference::apply("exec"s, "--help"s, VS({e.what()}));
return EXIT_FAILURE;
}
catch (const exception::error& e) {
std::cerr << cli::to_red("ERROR: ") << e.what() << std::endl;
return EXIT_FAILURE;
}
catch (const exception::warn& e) {
std::cout << cli::to_yellow("WARN: ") << e.what() << std::endl;
return EXIT_SUCCESS;
}
catch (const YAML::BadConversion& e) {
std::cout << cli::error << "poac.yml " << e.what()
<< std::endl;
return EXIT_SUCCESS;
}
catch (const std::invalid_argument& e) { // stoi error
return EXIT_SUCCESS;
}
catch (...) {
std::cerr << cli::to_error("Unexpected error") << std::endl;
return EXIT_FAILURE;
}
}