Added hopefully more details in image parsing errors, ref #723

This commit is contained in:
emeric
2025-08-05 23:01:07 +02:00
parent 35ba66099f
commit 92a8194844
13 changed files with 41 additions and 33 deletions
@@ -41,12 +41,12 @@ namespace lms::image::GraphicsMagick
catch (Magick::Warning& e)
{
LMS_LOG(COVER, WARNING, "Caught Magick warning: " << e.what());
throw Exception{ std::string{ "Magick read warning: " } + e.what() };
throw Exception{ std::string{ "Read warning: " } + e.what() };
}
catch (Magick::Exception& e)
{
LMS_LOG(COVER, ERROR, "Caught Magick exception: " << e.what());
throw Exception{ std::string{ "Magick read error: " } + e.what() };
throw Exception{ std::string{ "Read error: " } + e.what() };
}
}
@@ -63,12 +63,12 @@ namespace lms::image::GraphicsMagick
catch (Magick::Warning& e)
{
LMS_LOG(COVER, WARNING, "Caught Magick warning: " << e.what());
throw Exception{ std::string{ "Magick read warning: " } + e.what() };
throw Exception{ std::string{ "Read warning: " } + e.what() };
}
catch (Magick::Exception& e)
{
LMS_LOG(COVER, ERROR, "Caught Magick exception: " << e.what());
throw Exception{ std::string{ "Magick read error: " } + e.what() };
throw Exception{ std::string{ "Read error: " } + e.what() };
}
}
@@ -93,7 +93,7 @@ namespace lms::image::GraphicsMagick
catch (Magick::Exception& e)
{
LMS_LOG(COVER, ERROR, "Caught Magick exception while resizing: " << e.what());
throw Exception{ std::string{ "Magick resize error: " } + e.what() };
throw Exception{ std::string{ "Resize error: " } + e.what() };
}
}
+9 -6
View File
@@ -23,14 +23,17 @@
namespace lms::image
{
StbiException::StbiException(std::string_view desc)
: Exception{ std::string{ desc } + ": " + getLastFailureReason() }
namespace
{
}
std::string getLastStbiFailureReason()
{
const char* failureReason{ ::stbi_failure_reason() };
return failureReason ? failureReason : "unknown reason";
}
} // namespace
std::string StbiException::getLastFailureReason()
StbiException::StbiException(std::string_view desc)
: Exception{ std::string{ desc } + ": " + getLastStbiFailureReason() }
{
const char* failureReason{ ::stbi_failure_reason() };
return failureReason ? failureReason : "unknown reason";
}
} // namespace lms::image
-3
View File
@@ -29,8 +29,5 @@ namespace lms::image
{
public:
StbiException(std::string_view desc);
private:
static std::string getLastFailureReason();
};
} // namespace lms::image