comparison OrthancServer/main.cpp @ 1734:e2675b37eb01

Under Windows, the exit status of Orthanc corresponds to the encountered error code
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Oct 2015 14:28:57 +0200
parents e1f5ab395297
children 06addfcd1d4c
comparison
equal deleted inserted replaced
1733:e1f5ab395297 1734:e2675b37eb01
447 447
448 static void PrintErrors(const char* path) 448 static void PrintErrors(const char* path)
449 { 449 {
450 std::cout 450 std::cout
451 << path << " " << ORTHANC_VERSION << std::endl 451 << path << " " << ORTHANC_VERSION << std::endl
452 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research." << std::endl 452 << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
453 << "List of error codes that could be returned by Orthanc:" << std::endl << std::endl; 453 << std::endl << std::endl
454 << "List of error codes that could be returned by Orthanc:"
455 << std::endl << std::endl;
454 456
455 // The content of the following brackets is automatically generated 457 // The content of the following brackets is automatically generated
456 // by the "GenerateErrorCodes.py" script 458 // by the "GenerateErrorCodes.py" script
457 { 459 {
458 PrintErrorCode(ErrorCode_BadFileFormat, "tutu"); 460 PrintErrorCode(ErrorCode_InternalError, "Internal error");
461 PrintErrorCode(ErrorCode_Success, "Success");
462 PrintErrorCode(ErrorCode_Plugin, "Error encountered within the plugin engine");
463 PrintErrorCode(ErrorCode_NotImplemented, "Not implemented yet");
464 PrintErrorCode(ErrorCode_ParameterOutOfRange, "Parameter out of range");
465 PrintErrorCode(ErrorCode_NotEnoughMemory, "Not enough memory");
466 PrintErrorCode(ErrorCode_BadParameterType, "Bad type for a parameter");
467 PrintErrorCode(ErrorCode_BadSequenceOfCalls, "Bad sequence of calls");
468 PrintErrorCode(ErrorCode_InexistentItem, "Accessing an inexistent item");
469 PrintErrorCode(ErrorCode_BadRequest, "Bad request");
470 PrintErrorCode(ErrorCode_NetworkProtocol, "Error in the network protocol");
471 PrintErrorCode(ErrorCode_SystemCommand, "Error while calling a system command");
472 PrintErrorCode(ErrorCode_Database, "Error with the database engine");
473 PrintErrorCode(ErrorCode_UriSyntax, "Badly formatted URI");
474 PrintErrorCode(ErrorCode_InexistentFile, "Inexistent file");
475 PrintErrorCode(ErrorCode_CannotWriteFile, "Cannot write to file");
476 PrintErrorCode(ErrorCode_BadFileFormat, "Bad file format");
477 PrintErrorCode(ErrorCode_Timeout, "Timeout");
478 PrintErrorCode(ErrorCode_UnknownResource, "Unknown resource");
479 PrintErrorCode(ErrorCode_IncompatibleDatabaseVersion, "Incompatible version of the database");
480 PrintErrorCode(ErrorCode_FullStorage, "The file storage is full");
481 PrintErrorCode(ErrorCode_CorruptedFile, "Corrupted file (e.g. inconsistent MD5 hash)");
482 PrintErrorCode(ErrorCode_InexistentTag, "Inexistent tag");
483 PrintErrorCode(ErrorCode_ReadOnly, "Cannot modify a read-only data structure");
484 PrintErrorCode(ErrorCode_IncompatibleImageFormat, "Incompatible format of the images");
485 PrintErrorCode(ErrorCode_IncompatibleImageSize, "Incompatible size of the images");
486 PrintErrorCode(ErrorCode_SharedLibrary, "Error while using a shared library (plugin)");
487 PrintErrorCode(ErrorCode_UnknownPluginService, "Plugin invoking an unknown service");
488 PrintErrorCode(ErrorCode_UnknownDicomTag, "Unknown DICOM tag");
489 PrintErrorCode(ErrorCode_BadJson, "Cannot parse a JSON document");
490 PrintErrorCode(ErrorCode_Unauthorized, "Bad credentials were provided to an HTTP request");
491 PrintErrorCode(ErrorCode_BadFont, "Badly formatted font file");
492 PrintErrorCode(ErrorCode_DatabasePlugin, "The plugin implementing a custom database back-end does not fulfill the proper interface");
493 PrintErrorCode(ErrorCode_StorageAreaPlugin, "Error in the plugin implementing a custom storage area");
494 PrintErrorCode(ErrorCode_SQLiteNotOpened, "SQLite: The database is not opened");
495 PrintErrorCode(ErrorCode_SQLiteAlreadyOpened, "SQLite: Connection is already open");
496 PrintErrorCode(ErrorCode_SQLiteCannotOpen, "SQLite: Unable to open the database");
497 PrintErrorCode(ErrorCode_SQLiteStatementAlreadyUsed, "SQLite: This cached statement is already being referred to");
498 PrintErrorCode(ErrorCode_SQLiteExecute, "SQLite: Cannot execute a command");
499 PrintErrorCode(ErrorCode_SQLiteRollbackWithoutTransaction, "SQLite: Rolling back a nonexistent transaction (have you called Begin()?)");
500 PrintErrorCode(ErrorCode_SQLiteCommitWithoutTransaction, "SQLite: Committing a nonexistent transaction");
501 PrintErrorCode(ErrorCode_SQLiteRegisterFunction, "SQLite: Unable to register a function");
502 PrintErrorCode(ErrorCode_SQLiteFlush, "SQLite: Unable to flush the database");
503 PrintErrorCode(ErrorCode_SQLiteCannotRun, "SQLite: Cannot run a cached statement");
504 PrintErrorCode(ErrorCode_SQLiteCannotStep, "SQLite: Cannot step over a cached statement");
505 PrintErrorCode(ErrorCode_SQLiteBindOutOfRange, "SQLite: Bing a value while out of range (serious error)");
506 PrintErrorCode(ErrorCode_SQLitePrepareStatement, "SQLite: Cannot prepare a cached statement");
507 PrintErrorCode(ErrorCode_SQLiteTransactionAlreadyStarted, "SQLite: Beginning the same transaction twice");
508 PrintErrorCode(ErrorCode_SQLiteTransactionCommit, "SQLite: Failure when committing the transaction");
509 PrintErrorCode(ErrorCode_SQLiteTransactionBegin, "SQLite: Cannot start a transaction");
510 PrintErrorCode(ErrorCode_DirectoryOverFile, "The directory to be created is already occupied by a regular file");
511 PrintErrorCode(ErrorCode_FileStorageCannotWrite, "Unable to create a subdirectory or a file in the file storage");
512 PrintErrorCode(ErrorCode_DirectoryExpected, "The specified path does not point to a directory");
513 PrintErrorCode(ErrorCode_HttpPortInUse, "The TCP port of the HTTP server is already in use");
514 PrintErrorCode(ErrorCode_DicomPortInUse, "The TCP port of the DICOM server is already in use");
515 PrintErrorCode(ErrorCode_BadHttpStatusInRest, "This HTTP status is not allowed in a REST API");
516 PrintErrorCode(ErrorCode_RegularFileExpected, "The specified path does not point to a regular file");
517 PrintErrorCode(ErrorCode_PathToExecutable, "Unable to get the path to the executable");
518 PrintErrorCode(ErrorCode_MakeDirectory, "Cannot create a directory");
519 PrintErrorCode(ErrorCode_BadApplicationEntityTitle, "An application entity title (AET) cannot be empty or be longer than 16 characters");
520 PrintErrorCode(ErrorCode_NoCFindHandler, "No request handler factory for DICOM C-FIND SCP");
521 PrintErrorCode(ErrorCode_NoCMoveHandler, "No request handler factory for DICOM C-MOVE SCP");
522 PrintErrorCode(ErrorCode_NoCStoreHandler, "No request handler factory for DICOM C-STORE SCP");
523 PrintErrorCode(ErrorCode_NoApplicationEntityFilter, "No application entity filter");
524 PrintErrorCode(ErrorCode_NoSopClassOrInstance, "DicomUserConnection: Unable to find the SOP class and instance");
525 PrintErrorCode(ErrorCode_NoPresentationContext, "DicomUserConnection: No acceptable presentation context for modality");
526 PrintErrorCode(ErrorCode_DicomFindUnavailable, "DicomUserConnection: The C-FIND command is not supported by the remote SCP");
527 PrintErrorCode(ErrorCode_DicomMoveUnavailable, "DicomUserConnection: The C-MOVE command is not supported by the remote SCP");
528 PrintErrorCode(ErrorCode_CannotStoreInstance, "Cannot store an instance");
529 PrintErrorCode(ErrorCode_CreateDicomNotString, "Only string values are supported when creating DICOM instances");
530 PrintErrorCode(ErrorCode_CreateDicomOverrideTag, "Trying to override a value inherited from a parent module");
531 PrintErrorCode(ErrorCode_CreateDicomUseContent, "Use \"Content\" to inject an image into a new DICOM instance");
532 PrintErrorCode(ErrorCode_CreateDicomNoPayload, "No payload is present for one instance in the series");
533 PrintErrorCode(ErrorCode_CreateDicomUseDataUriScheme, "The payload of the DICOM instance must be specified according to Data URI scheme");
534 PrintErrorCode(ErrorCode_CreateDicomBadParent, "Trying to attach a new DICOM instance to an inexistent resource");
535 PrintErrorCode(ErrorCode_CreateDicomParentIsInstance, "Trying to attach a new DICOM instance to an instance (must be a series, study or patient)");
536 PrintErrorCode(ErrorCode_CreateDicomParentEncoding, "Unable to get the encoding of the parent resource");
537 PrintErrorCode(ErrorCode_UnknownModality, "Unknown modality");
538 PrintErrorCode(ErrorCode_BadJobOrdering, "Bad ordering of filters in a job");
539 PrintErrorCode(ErrorCode_JsonToLuaTable, "Cannot convert the given JSON object to a Lua table");
540 PrintErrorCode(ErrorCode_CannotCreateLua, "Cannot create the Lua context");
541 PrintErrorCode(ErrorCode_CannotExecuteLua, "Cannot execute a Lua command");
542 PrintErrorCode(ErrorCode_LuaAlreadyExecuted, "Arguments cannot be pushed after the Lua function is executed");
543 PrintErrorCode(ErrorCode_LuaBadOutput, "The Lua function does not give the expected number of outputs");
544 PrintErrorCode(ErrorCode_NotLuaPredicate, "The Lua function is not a predicate (only true/false outputs allowed)");
545 PrintErrorCode(ErrorCode_LuaReturnsNoString, "The Lua function does not return a string");
546 PrintErrorCode(ErrorCode_StorageAreaAlreadyRegistered, "Another plugin has already registered a custom storage area");
547 PrintErrorCode(ErrorCode_DatabaseBackendAlreadyRegistered, "Another plugin has already registered a custom database back-end");
548 PrintErrorCode(ErrorCode_DatabaseNotInitialized, "Plugin trying to call the database during its initialization");
549 PrintErrorCode(ErrorCode_SslDisabled, "Orthanc has been built without SSL support");
550 PrintErrorCode(ErrorCode_CannotOrderSlices, "Unable to order the slices of the series");
459 } 551 }
460 552
461 std::cout << std::endl; 553 std::cout << std::endl;
462 } 554 }
463 555
973 } 1065 }
974 catch (const OrthancException& e) 1066 catch (const OrthancException& e)
975 { 1067 {
976 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.What() << "] (code " << e.GetErrorCode() << ")"; 1068 LOG(ERROR) << "Uncaught exception, stopping now: [" << e.What() << "] (code " << e.GetErrorCode() << ")";
977 #if defined(_WIN32) 1069 #if defined(_WIN32)
978 status = static_cast<int>(e.GetErrorCode()); 1070 if (e.GetErrorCode() >= ErrorCode_START_PLUGINS)
1071 {
1072 status = static_cast<int>(ErrorCode_Plugin);
1073 }
1074 else
1075 {
1076 status = static_cast<int>(e.GetErrorCode());
1077 }
1078
979 #else 1079 #else
980 status = -1; 1080 status = -1;
981 #endif 1081 #endif
982 } 1082 }
983 catch (const std::exception& e) 1083 catch (const std::exception& e)