changeset 1568:818ae9bc493a

error description in json
author jodogne
date Sun, 23 Aug 2015 09:55:23 +0200
parents 9c5d93510414
children 27774f6f84e4
files Core/HttpServer/MongooseServer.cpp Core/OrthancException.cpp
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Sun Aug 23 09:49:16 2015 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Sun Aug 23 09:55:23 2015 +0200
@@ -749,7 +749,14 @@
             break;
 
           default:
-            output.SendStatus(HttpStatus_500_InternalServerError, e.What());
+	    {
+	      Json::Value message = Json::objectValue;
+	      message["ErrorCode"] = e.GetErrorCode();
+	      message["Description"] = e.GetDescription(e.GetErrorCode());
+	      message["Message"] = e.What();
+	      std::string s = message.toStyledString();
+	      output.SendStatus(HttpStatus_500_InternalServerError, s);
+	    }
         }
       }
       catch (OrthancException&)
--- a/Core/OrthancException.cpp	Sun Aug 23 09:49:16 2015 +0200
+++ b/Core/OrthancException.cpp	Sun Aug 23 09:55:23 2015 +0200
@@ -134,8 +134,10 @@
         return "Error with the database engine";
 
       case ErrorCode_Custom:
+        return "See the attached error message";
+
       default:
-        return "???";
+        return "Unknown error code";
     }
   }
 }