| 360 | } |
| 361 | |
| 362 | int main(int args_size, char *args[]) |
| 363 | { |
| 364 | std::ios::sync_with_stdio(false); |
| 365 | int errorcode = 0; |
| 366 | try { |
| 367 | covscript_main(args_size, args); |
| 368 | errorcode = cs::current_process->exit_code; |
| 369 | } |
| 370 | catch (const std::exception &e) { |
| 371 | if (!log_path.empty()) { |
| 372 | std::ofstream out(::log_path); |
| 373 | if (out) { |
| 374 | out << e.what(); |
| 375 | out.flush(); |
| 376 | } |
| 377 | else |
| 378 | std::cerr << "Write log failed." << std::endl; |
| 379 | } |
| 380 | std::cerr << e.what() << std::endl; |
| 381 | errorcode = -1; |
| 382 | } |
| 383 | catch (...) { |
| 384 | if (!log_path.empty()) { |
| 385 | std::ofstream out(::log_path); |
| 386 | if (out) { |
| 387 | out << "Uncaught exception: Unknown exception"; |
| 388 | out.flush(); |
| 389 | } |
| 390 | else |
| 391 | std::cerr << "Write log failed." << std::endl; |
| 392 | } |
| 393 | std::cerr << "Uncaught exception: Unknown exception" << std::endl; |
| 394 | errorcode = -1; |
| 395 | } |
| 396 | if (wait_before_exit) { |
| 397 | std::cerr << "\nProcess finished with exit code " << errorcode << std::endl; |
| 398 | std::cerr << "\nPress any key to exit..." << std::endl; |
| 399 | while (!cs_impl::conio::kbhit()); |
| 400 | cs_impl::conio::getch(); |
| 401 | } |
| 402 | return errorcode; |
| 403 | } |
nothing calls this directly
no test coverage detected