Mercurial > hg > orthanc
changeset 1596:f2e3d030ea59
BadJson error code
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 27 Aug 2015 15:36:43 +0200 |
parents | e1e54a73ba8b |
children | 415dfd1d1c61 |
files | Core/Enumerations.cpp Core/Enumerations.h Core/Lua/LuaContext.cpp OrthancServer/OrthancInitialization.cpp Plugins/Include/orthanc/OrthancCPlugin.h Resources/ErrorCodes.json |
diffstat | 6 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Thu Aug 27 14:58:58 2015 +0200 +++ b/Core/Enumerations.cpp Thu Aug 27 15:36:43 2015 +0200 @@ -133,6 +133,9 @@ case ErrorCode_UnknownDicomTag: return "Unknown DICOM tag"; + case ErrorCode_BadJson: + return "Cannot parse a JSON document"; + case ErrorCode_SQLiteNotOpened: return "SQLite: The database is not opened"; @@ -1118,6 +1121,9 @@ case ErrorCode_InexistentTag: return HttpStatus_404_NotFound; + case ErrorCode_BadJson: + return HttpStatus_400_BadRequest; + default: return HttpStatus_500_InternalServerError; }
--- a/Core/Enumerations.h Thu Aug 27 14:58:58 2015 +0200 +++ b/Core/Enumerations.h Thu Aug 27 15:36:43 2015 +0200 @@ -74,6 +74,7 @@ ErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, ErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, ErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, + ErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, ErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, ErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, ErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
--- a/Core/Lua/LuaContext.cpp Thu Aug 27 14:58:58 2015 +0200 +++ b/Core/Lua/LuaContext.cpp Thu Aug 27 15:36:43 2015 +0200 @@ -557,7 +557,7 @@ Json::Reader reader; if (!reader.parse(s, output)) { - throw OrthancException(ErrorCode_BadFileFormat); + throw OrthancException(ErrorCode_BadJson); } }
--- a/OrthancServer/OrthancInitialization.cpp Thu Aug 27 14:58:58 2015 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Thu Aug 27 15:36:43 2015 +0200 @@ -137,8 +137,8 @@ if (!reader.parse(content, tmp) || tmp.type() != Json::objectValue) { - LOG(ERROR) << "Bad file format for this configuration file: " << path; - throw OrthancException(ErrorCode_BadFileFormat); + LOG(ERROR) << "The configuration file does not follow the JSON syntax: " << path; + throw OrthancException(ErrorCode_BadJson); } Toolbox::CopyJsonWithoutComments(config, tmp);
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Thu Aug 27 14:58:58 2015 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Thu Aug 27 15:36:43 2015 +0200 @@ -192,6 +192,7 @@ OrthancPluginErrorCode_SharedLibrary = 25 /*!< Error while using a shared library (plugin) */, OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, + OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */,
--- a/Resources/ErrorCodes.json Thu Aug 27 14:58:58 2015 +0200 +++ b/Resources/ErrorCodes.json Thu Aug 27 15:36:43 2015 +0200 @@ -160,8 +160,9 @@ }, { "Code": 28, - "Name": "RegularFileExpected", - "Description": "The path does not point to a regular file" + "HttpStatus": 400, + "Name": "BadJson", + "Description": "Cannot parse a JSON document" },