From 350a79d324ab2831c0583d8adc9708e7a5d7357a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 19 Mar 2020 11:41:21 +0100 Subject: [PATCH] TgaImporter: make error messages consistent. --- src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp | 4 ++-- src/MagnumPlugins/TgaImporter/TgaImporter.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp b/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp index b95ac4c29..2c22ca017 100644 --- a/src/MagnumPlugins/TgaImporter/Test/TgaImporterTest.cpp +++ b/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), diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp index 211135707..8e581b2b0 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.cpp +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.cpp @@ -73,8 +73,8 @@ UnsignedInt TgaImporter::doImage2DCount() const { return 1; } Containers::Optional 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 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; }