diff Core/Compression/ZipWriter.cpp @ 1582:bd1889029cbb

encoding of exceptions
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 17:39:38 +0200
parents 6e7e5ed91c2d
children b1291df2f780
line wrap: on
line diff
--- a/Core/Compression/ZipWriter.cpp	Tue Aug 25 16:18:37 2015 +0200
+++ b/Core/Compression/ZipWriter.cpp	Tue Aug 25 17:39:38 2015 +0200
@@ -44,6 +44,7 @@
 
 #include "../../Resources/ThirdParty/minizip/zip.h"
 #include "../OrthancException.h"
+#include "../Logging.h"
 
 
 static void PrepareFileInfo(zip_fileinfo& zfi)
@@ -122,7 +123,8 @@
 
     if (path_.size() == 0)
     {
-      throw OrthancException("Please call SetOutputPath() before creating the file");
+      LOG(ERROR) << "Please call SetOutputPath() before creating the file";
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
     hasFileInZip_ = false;
@@ -165,7 +167,8 @@
   {
     if (level >= 10)
     {
-      throw OrthancException("ZIP compression level must be between 0 (no compression) and 9 (highest compression");
+      LOG(ERROR) << "ZIP compression level must be between 0 (no compression) and 9 (highest compression)";
+      throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
 
     Close();
@@ -224,7 +227,8 @@
   {
     if (!hasFileInZip_)
     {
-      throw OrthancException("Call first OpenFile()");
+      LOG(ERROR) << "Call first OpenFile()";
+      throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
     const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max();