comparison Core/Compression/DeflateBaseCompressor.cpp @ 2954:d924f9bb61cc

taking advantage of details in OrthancException
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Dec 2018 14:35:34 +0100
parents 878b59270859
children 4e43e67f8ecf
comparison
equal deleted inserted replaced
2953:210d5afd8f2b 2954:d924f9bb61cc
43 { 43 {
44 void DeflateBaseCompressor::SetCompressionLevel(uint8_t level) 44 void DeflateBaseCompressor::SetCompressionLevel(uint8_t level)
45 { 45 {
46 if (level >= 10) 46 if (level >= 10)
47 { 47 {
48 LOG(ERROR) << "Zlib compression level must be between 0 (no compression) and 9 (highest compression)"; 48 throw OrthancException(ErrorCode_ParameterOutOfRange,
49 throw OrthancException(ErrorCode_ParameterOutOfRange); 49 "Zlib compression level must be between 0 (no compression) and 9 (highest compression)");
50 } 50 }
51 51
52 compressionLevel_ = level; 52 compressionLevel_ = level;
53 } 53 }
54 54
61 return 0; 61 return 0;
62 } 62 }
63 63
64 if (compressedSize < sizeof(uint64_t)) 64 if (compressedSize < sizeof(uint64_t))
65 { 65 {
66 LOG(ERROR) << "The compressed buffer is ill-formed"; 66 throw OrthancException(ErrorCode_CorruptedFile, "The compressed buffer is ill-formed");
67 throw OrthancException(ErrorCode_CorruptedFile);
68 } 67 }
69 68
70 uint64_t size; 69 uint64_t size;
71 memcpy(&size, compressed, sizeof(uint64_t)); 70 memcpy(&size, compressed, sizeof(uint64_t));
72 71