Browse Source

TgaImporter: make error messages consistent.

pull/430/head
Vladimír Vondruš 6 years ago
parent
commit
350a79d324
  1. 4
      src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp
  2. 6
      src/MagnumPlugins/TgaImporter/TgaImporter.cpp

4
src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp

@ -101,9 +101,9 @@ constexpr struct {
const char* message;
} ShortData[] {
{"short header", Containers::arrayView(Color24).prefix(17),
"the file is too short: 17 bytes"},
"file too short, expected at least 18 bytes but got 17"},
{"short data", Containers::arrayView(Color24).except(1),
"the file is too short: got 35 bytes but expected 36"},
"file too short, expected 36 bytes but got 35"},
{"short RLE data", Containers::arrayView(Color24Rle).except(1),
"RLE file too short at pixel 3"},
{"short RLE raw data", Containers::arrayView(Color24Rle).except(5),

6
src/MagnumPlugins/TgaImporter/TgaImporter.cpp

@ -73,8 +73,8 @@ UnsignedInt TgaImporter::doImage2DCount() const { return 1; }
Containers::Optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt, UnsignedInt) {
/* Check if the file is long enough */
if(_in.size() < std::streamoff(sizeof(Implementation::TgaHeader))) {
Error() << "Trade::TgaImporter::image2D(): the file is too short:" << _in.size() << "bytes";
if(_in.size() < sizeof(Implementation::TgaHeader)) {
Error{} << "Trade::TgaImporter::image2D(): file too short, expected at least" << sizeof(Implementation::TgaHeader) << "bytes but got" << _in.size();
return Containers::NullOpt;
}
@ -135,7 +135,7 @@ Containers::Optional<ImageData2D> TgaImporter::doImage2D(UnsignedInt, UnsignedIn
if(!rle) {
/* Files that are larger are allowed in this case (but not for RLE) */
if(srcPixels.size() < outputSize) {
Error{} << "Trade::TgaImporter::image2D(): the file is too short: got" << _in.size() << "bytes but expected" << outputSize + sizeof(Implementation::TgaHeader);
Error{} << "Trade::TgaImporter::image2D(): file too short, expected" << outputSize + sizeof(Implementation::TgaHeader) << "bytes but got" << _in.size();
return Containers::NullOpt;
}

Loading…
Cancel
Save