# HG changeset patch # User Sebastien Jodogne # Date 1442579327 -7200 # Node ID 8dc468f4466115f671e2a4199dc44f887d35bbbf # Parent c17b1142caab945a049b85601ff91072f927d1b5 mapping of error codes from plugins to Orthanc diff -r c17b1142caab -r 8dc468f44661 Plugins/Engine/PluginsEnumerations.cpp --- a/Plugins/Engine/PluginsEnumerations.cpp Fri Sep 18 12:58:51 2015 +0200 +++ b/Plugins/Engine/PluginsEnumerations.cpp Fri Sep 18 14:28:47 2015 +0200 @@ -39,6 +39,268 @@ { namespace Plugins { + ErrorCode Convert(OrthancPluginErrorCode error) + { + switch (error) + { + case OrthancPluginErrorCode_InternalError: + return ErrorCode_InternalError; + + case OrthancPluginErrorCode_Success: + return ErrorCode_Success; + + case OrthancPluginErrorCode_Plugin: + return ErrorCode_Plugin; + + case OrthancPluginErrorCode_NotImplemented: + return ErrorCode_NotImplemented; + + case OrthancPluginErrorCode_ParameterOutOfRange: + return ErrorCode_ParameterOutOfRange; + + case OrthancPluginErrorCode_NotEnoughMemory: + return ErrorCode_NotEnoughMemory; + + case OrthancPluginErrorCode_BadParameterType: + return ErrorCode_BadParameterType; + + case OrthancPluginErrorCode_BadSequenceOfCalls: + return ErrorCode_BadSequenceOfCalls; + + case OrthancPluginErrorCode_InexistentItem: + return ErrorCode_InexistentItem; + + case OrthancPluginErrorCode_BadRequest: + return ErrorCode_BadRequest; + + case OrthancPluginErrorCode_NetworkProtocol: + return ErrorCode_NetworkProtocol; + + case OrthancPluginErrorCode_SystemCommand: + return ErrorCode_SystemCommand; + + case OrthancPluginErrorCode_Database: + return ErrorCode_Database; + + case OrthancPluginErrorCode_UriSyntax: + return ErrorCode_UriSyntax; + + case OrthancPluginErrorCode_InexistentFile: + return ErrorCode_InexistentFile; + + case OrthancPluginErrorCode_CannotWriteFile: + return ErrorCode_CannotWriteFile; + + case OrthancPluginErrorCode_BadFileFormat: + return ErrorCode_BadFileFormat; + + case OrthancPluginErrorCode_Timeout: + return ErrorCode_Timeout; + + case OrthancPluginErrorCode_UnknownResource: + return ErrorCode_UnknownResource; + + case OrthancPluginErrorCode_IncompatibleDatabaseVersion: + return ErrorCode_IncompatibleDatabaseVersion; + + case OrthancPluginErrorCode_FullStorage: + return ErrorCode_FullStorage; + + case OrthancPluginErrorCode_CorruptedFile: + return ErrorCode_CorruptedFile; + + case OrthancPluginErrorCode_InexistentTag: + return ErrorCode_InexistentTag; + + case OrthancPluginErrorCode_ReadOnly: + return ErrorCode_ReadOnly; + + case OrthancPluginErrorCode_IncompatibleImageFormat: + return ErrorCode_IncompatibleImageFormat; + + case OrthancPluginErrorCode_IncompatibleImageSize: + return ErrorCode_IncompatibleImageSize; + + case OrthancPluginErrorCode_SharedLibrary: + return ErrorCode_SharedLibrary; + + case OrthancPluginErrorCode_UnknownPluginService: + return ErrorCode_UnknownPluginService; + + case OrthancPluginErrorCode_UnknownDicomTag: + return ErrorCode_UnknownDicomTag; + + case OrthancPluginErrorCode_BadJson: + return ErrorCode_BadJson; + + case OrthancPluginErrorCode_Unauthorized: + return ErrorCode_Unauthorized; + + case OrthancPluginErrorCode_BadFont: + return ErrorCode_BadFont; + + case OrthancPluginErrorCode_SQLiteNotOpened: + return ErrorCode_SQLiteNotOpened; + + case OrthancPluginErrorCode_SQLiteAlreadyOpened: + return ErrorCode_SQLiteAlreadyOpened; + + case OrthancPluginErrorCode_SQLiteCannotOpen: + return ErrorCode_SQLiteCannotOpen; + + case OrthancPluginErrorCode_SQLiteStatementAlreadyUsed: + return ErrorCode_SQLiteStatementAlreadyUsed; + + case OrthancPluginErrorCode_SQLiteExecute: + return ErrorCode_SQLiteExecute; + + case OrthancPluginErrorCode_SQLiteRollbackWithoutTransaction: + return ErrorCode_SQLiteRollbackWithoutTransaction; + + case OrthancPluginErrorCode_SQLiteCommitWithoutTransaction: + return ErrorCode_SQLiteCommitWithoutTransaction; + + case OrthancPluginErrorCode_SQLiteRegisterFunction: + return ErrorCode_SQLiteRegisterFunction; + + case OrthancPluginErrorCode_SQLiteFlush: + return ErrorCode_SQLiteFlush; + + case OrthancPluginErrorCode_SQLiteCannotRun: + return ErrorCode_SQLiteCannotRun; + + case OrthancPluginErrorCode_SQLiteCannotStep: + return ErrorCode_SQLiteCannotStep; + + case OrthancPluginErrorCode_SQLiteBindOutOfRange: + return ErrorCode_SQLiteBindOutOfRange; + + case OrthancPluginErrorCode_SQLitePrepareStatement: + return ErrorCode_SQLitePrepareStatement; + + case OrthancPluginErrorCode_SQLiteTransactionAlreadyStarted: + return ErrorCode_SQLiteTransactionAlreadyStarted; + + case OrthancPluginErrorCode_SQLiteTransactionCommit: + return ErrorCode_SQLiteTransactionCommit; + + case OrthancPluginErrorCode_SQLiteTransactionBegin: + return ErrorCode_SQLiteTransactionBegin; + + case OrthancPluginErrorCode_DirectoryOverFile: + return ErrorCode_DirectoryOverFile; + + case OrthancPluginErrorCode_FileStorageCannotWrite: + return ErrorCode_FileStorageCannotWrite; + + case OrthancPluginErrorCode_DirectoryExpected: + return ErrorCode_DirectoryExpected; + + case OrthancPluginErrorCode_HttpPortInUse: + return ErrorCode_HttpPortInUse; + + case OrthancPluginErrorCode_DicomPortInUse: + return ErrorCode_DicomPortInUse; + + case OrthancPluginErrorCode_BadHttpStatusInRest: + return ErrorCode_BadHttpStatusInRest; + + case OrthancPluginErrorCode_RegularFileExpected: + return ErrorCode_RegularFileExpected; + + case OrthancPluginErrorCode_PathToExecutable: + return ErrorCode_PathToExecutable; + + case OrthancPluginErrorCode_MakeDirectory: + return ErrorCode_MakeDirectory; + + case OrthancPluginErrorCode_BadApplicationEntityTitle: + return ErrorCode_BadApplicationEntityTitle; + + case OrthancPluginErrorCode_NoCFindHandler: + return ErrorCode_NoCFindHandler; + + case OrthancPluginErrorCode_NoCMoveHandler: + return ErrorCode_NoCMoveHandler; + + case OrthancPluginErrorCode_NoCStoreHandler: + return ErrorCode_NoCStoreHandler; + + case OrthancPluginErrorCode_NoApplicationEntityFilter: + return ErrorCode_NoApplicationEntityFilter; + + case OrthancPluginErrorCode_NoSopClassOrInstance: + return ErrorCode_NoSopClassOrInstance; + + case OrthancPluginErrorCode_NoPresentationContext: + return ErrorCode_NoPresentationContext; + + case OrthancPluginErrorCode_DicomFindUnavailable: + return ErrorCode_DicomFindUnavailable; + + case OrthancPluginErrorCode_DicomMoveUnavailable: + return ErrorCode_DicomMoveUnavailable; + + case OrthancPluginErrorCode_CannotStoreInstance: + return ErrorCode_CannotStoreInstance; + + case OrthancPluginErrorCode_CreateDicomNotString: + return ErrorCode_CreateDicomNotString; + + case OrthancPluginErrorCode_CreateDicomOverrideTag: + return ErrorCode_CreateDicomOverrideTag; + + case OrthancPluginErrorCode_CreateDicomUseContent: + return ErrorCode_CreateDicomUseContent; + + case OrthancPluginErrorCode_CreateDicomNoPayload: + return ErrorCode_CreateDicomNoPayload; + + case OrthancPluginErrorCode_CreateDicomUseDataUriScheme: + return ErrorCode_CreateDicomUseDataUriScheme; + + case OrthancPluginErrorCode_CreateDicomBadParent: + return ErrorCode_CreateDicomBadParent; + + case OrthancPluginErrorCode_CreateDicomParentIsInstance: + return ErrorCode_CreateDicomParentIsInstance; + + case OrthancPluginErrorCode_CreateDicomParentEncoding: + return ErrorCode_CreateDicomParentEncoding; + + case OrthancPluginErrorCode_UnknownModality: + return ErrorCode_UnknownModality; + + case OrthancPluginErrorCode_BadJobOrdering: + return ErrorCode_BadJobOrdering; + + case OrthancPluginErrorCode_JsonToLuaTable: + return ErrorCode_JsonToLuaTable; + + case OrthancPluginErrorCode_CannotCreateLua: + return ErrorCode_CannotCreateLua; + + case OrthancPluginErrorCode_CannotExecuteLua: + return ErrorCode_CannotExecuteLua; + + case OrthancPluginErrorCode_LuaAlreadyExecuted: + return ErrorCode_LuaAlreadyExecuted; + + case OrthancPluginErrorCode_LuaBadOutput: + return ErrorCode_LuaBadOutput; + + case OrthancPluginErrorCode_NotLuaPredicate: + return ErrorCode_NotLuaPredicate; + + case OrthancPluginErrorCode_LuaReturnsNoString: + return ErrorCode_LuaReturnsNoString; + + default: + return ErrorCode_Plugin; + } + } + + OrthancPluginResourceType Convert(ResourceType type) { switch (type) diff -r c17b1142caab -r 8dc468f44661 Plugins/Engine/PluginsEnumerations.h --- a/Plugins/Engine/PluginsEnumerations.h Fri Sep 18 12:58:51 2015 +0200 +++ b/Plugins/Engine/PluginsEnumerations.h Fri Sep 18 14:28:47 2015 +0200 @@ -40,6 +40,8 @@ { namespace Plugins { + ErrorCode Convert(OrthancPluginErrorCode error); + OrthancPluginResourceType Convert(ResourceType type); OrthancPluginChangeType Convert(ChangeType type); diff -r c17b1142caab -r 8dc468f44661 Resources/GenerateErrorCodes.py --- a/Resources/GenerateErrorCodes.py Fri Sep 18 12:58:51 2015 +0200 +++ b/Resources/GenerateErrorCodes.py Fri Sep 18 14:28:47 2015 +0200 @@ -132,3 +132,21 @@ with open(path, 'w') as f: f.write(a) + + + +## +## Generate the "Plugins::Convert(OrthancPluginErrorCode)" in +## "PluginsEnumerations.cpp" +## + +path = os.path.join(BASE, 'Plugins', 'Engine', 'PluginsEnumerations.cpp') +with open(path, 'r') as f: + a = f.read() + +s = '\n\n'.join(map(lambda x: ' case OrthancPluginErrorCode_%s:\n return ErrorCode_%s;' % (x['Name'], x['Name']), ERRORS)) +a = re.sub('(Convert\(OrthancPluginErrorCode.*?\)\s*{\s*switch \([^)]*?\)\s*{)[^}]*?(\s*default:)', + r'\1\n%s\2' % s, a, re.DOTALL) + +with open(path, 'w') as f: + f.write(a)