comparison Core/Compression/DeflateBaseCompressor.cpp @ 1582:bd1889029cbb

encoding of exceptions
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 17:39:38 +0200
parents fe07f82d83d3
children b1291df2f780
comparison
equal deleted inserted replaced
1581:357c4bb15701 1582:bd1889029cbb
32 32
33 #include "../PrecompiledHeaders.h" 33 #include "../PrecompiledHeaders.h"
34 #include "DeflateBaseCompressor.h" 34 #include "DeflateBaseCompressor.h"
35 35
36 #include "../OrthancException.h" 36 #include "../OrthancException.h"
37 #include "../Logging.h"
37 38
38 #include <string.h> 39 #include <string.h>
39 40
40 namespace Orthanc 41 namespace Orthanc
41 { 42 {
42 void DeflateBaseCompressor::SetCompressionLevel(uint8_t level) 43 void DeflateBaseCompressor::SetCompressionLevel(uint8_t level)
43 { 44 {
44 if (level >= 10) 45 if (level >= 10)
45 { 46 {
46 throw OrthancException("Zlib compression level must be between 0 (no compression) and 9 (highest compression"); 47 LOG(ERROR) << "Zlib compression level must be between 0 (no compression) and 9 (highest compression)";
48 throw OrthancException(ErrorCode_ParameterOutOfRange);
47 } 49 }
48 50
49 compressionLevel_ = level; 51 compressionLevel_ = level;
50 } 52 }
51 53
58 return 0; 60 return 0;
59 } 61 }
60 62
61 if (compressedSize < sizeof(uint64_t)) 63 if (compressedSize < sizeof(uint64_t))
62 { 64 {
63 throw OrthancException("The compressed buffer is ill-formed"); 65 LOG(ERROR) << "The compressed buffer is ill-formed";
66 throw OrthancException(ErrorCode_CorruptedFile);
64 } 67 }
65 68
66 uint64_t size; 69 uint64_t size;
67 memcpy(&size, compressed, sizeof(uint64_t)); 70 memcpy(&size, compressed, sizeof(uint64_t));
68 71