Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 1733:e1f5ab395297
PrintErrors
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 21 Oct 2015 14:10:55 +0200 |
parents | bc34c69b594a |
children | e2675b37eb01 |
comparison
equal
deleted
inserted
replaced
1732:5cdea1cd2071 | 1733:e1f5ab395297 |
---|---|
385 } | 385 } |
386 }; | 386 }; |
387 | 387 |
388 | 388 |
389 | 389 |
390 static void PrintHelp(char* path) | 390 static void PrintHelp(const char* path) |
391 { | 391 { |
392 std::cout | 392 std::cout |
393 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl | 393 << "Usage: " << path << " [OPTION]... [CONFIGURATION]" << std::endl |
394 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl | 394 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl |
395 << std::endl | 395 << std::endl |
402 << "Command-line options:" << std::endl | 402 << "Command-line options:" << std::endl |
403 << " --help\t\tdisplay this help and exit" << std::endl | 403 << " --help\t\tdisplay this help and exit" << std::endl |
404 << " --logdir=[dir]\tdirectory where to store the log files" << std::endl | 404 << " --logdir=[dir]\tdirectory where to store the log files" << std::endl |
405 << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl | 405 << "\t\t\t(if not used, the logs are dumped to stderr)" << std::endl |
406 << " --config=[file]\tcreate a sample configuration file and exit" << std::endl | 406 << " --config=[file]\tcreate a sample configuration file and exit" << std::endl |
407 << " --errors\t\tprint the supported error codes and exit" << std::endl | |
407 << " --verbose\t\tbe verbose in logs" << std::endl | 408 << " --verbose\t\tbe verbose in logs" << std::endl |
408 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl | 409 << " --trace\t\thighest verbosity in logs (for debug)" << std::endl |
409 << " --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl | 410 << " --upgrade\t\tallow Orthanc to upgrade the version of the" << std::endl |
410 << "\t\t\tdatabase (beware that the database will become" << std::endl | 411 << "\t\t\tdatabase (beware that the database will become" << std::endl |
411 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl | 412 << "\t\t\tincompatible with former versions of Orthanc)" << std::endl |
412 << " --version\t\toutput version information and exit" << std::endl | 413 << " --version\t\toutput version information and exit" << std::endl |
413 << std::endl | 414 << std::endl |
414 << "Exit status:" << std::endl | 415 << "Exit status:" << std::endl |
415 << " 0 if success," << std::endl | 416 << " 0 if success," << std::endl |
417 #if defined(_WIN32) | |
418 << "!= 0 if error (use the --errors option to get the list of possible errors)." << std::endl | |
419 #else | |
416 << " -1 if error (have a look at the logs)." << std::endl | 420 << " -1 if error (have a look at the logs)." << std::endl |
421 #endif | |
417 << std::endl; | 422 << std::endl; |
418 } | 423 } |
419 | 424 |
420 | 425 |
421 static void PrintVersion(char* path) | 426 static void PrintVersion(const char* path) |
422 { | 427 { |
423 std::cout | 428 std::cout |
424 << path << " " << ORTHANC_VERSION << std::endl | 429 << path << " " << ORTHANC_VERSION << std::endl |
425 << "Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics Department, University Hospital of Liege (Belgium)" << std::endl | 430 << "Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics Department, University Hospital of Liege (Belgium)" << std::endl |
426 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl | 431 << "Licensing GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>, with OpenSSL exception." << std::endl |
427 << "This is free software: you are free to change and redistribute it." << std::endl | 432 << "This is free software: you are free to change and redistribute it." << std::endl |
428 << "There is NO WARRANTY, to the extent permitted by law." << std::endl | 433 << "There is NO WARRANTY, to the extent permitted by law." << std::endl |
429 << std::endl | 434 << std::endl |
430 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl; | 435 << "Written by Sebastien Jodogne <s.jodogne@gmail.com>" << std::endl; |
436 } | |
437 | |
438 | |
439 static void PrintErrorCode(ErrorCode code, const char* description) | |
440 { | |
441 std::cout | |
442 << std::right << std::setw(16) | |
443 << static_cast<int>(code) | |
444 << " " << description << std::endl; | |
445 } | |
446 | |
447 | |
448 static void PrintErrors(const char* path) | |
449 { | |
450 std::cout | |
451 << path << " " << ORTHANC_VERSION << std::endl | |
452 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl | |
453 << "List of error codes that could be returned by Orthanc:" << std::endl << std::endl; | |
454 | |
455 // The content of the following brackets is automatically generated | |
456 // by the "GenerateErrorCodes.py" script | |
457 { | |
458 PrintErrorCode(ErrorCode_BadFileFormat, "tutu"); | |
459 } | |
460 | |
461 std::cout << std::endl; | |
431 } | 462 } |
432 | 463 |
433 | 464 |
434 | 465 |
435 static void LoadLuaScripts(ServerContext& context) | 466 static void LoadLuaScripts(ServerContext& context) |
851 // Use the first argument that does not start with a "-" as | 882 // Use the first argument that does not start with a "-" as |
852 // the configuration file | 883 // the configuration file |
853 configurationFile = argv[i]; | 884 configurationFile = argv[i]; |
854 } | 885 } |
855 } | 886 } |
887 else if (argument == "--errors") | |
888 { | |
889 PrintErrors(argv[0]); | |
890 return 0; | |
891 } | |
856 else if (argument == "--help") | 892 else if (argument == "--help") |
857 { | 893 { |
858 PrintHelp(argv[0]); | 894 PrintHelp(argv[0]); |
859 return 0; | 895 return 0; |
860 } | 896 } |
935 } | 971 } |
936 } | 972 } |
937 } | 973 } |
938 catch (const OrthancException& e) | 974 catch (const OrthancException& e) |
939 { | 975 { |
940 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.What() << "]"; | 976 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.What() << "] (code " << e.GetErrorCode() << ")"; |
977 #if defined(_WIN32) | |
978 status = static_cast<int>(e.GetErrorCode()); | |
979 #else | |
941 status = -1; | 980 status = -1; |
981 #endif | |
942 } | 982 } |
943 catch (const std::exception& e) | 983 catch (const std::exception& e) |
944 { | 984 { |
945 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.what() << "]"; | 985 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.what() << "]"; |
946 status = -1; | 986 status = -1; |