From 6e94848aec5d42eed5f9e1f5548ade26915ce90b Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 4 Jun 2024 21:14:45 +0100 Subject: Tidy many stringy messes with std::format --- gfx/image.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gfx/image.cpp') diff --git a/gfx/image.cpp b/gfx/image.cpp index fb86cb6..3b63054 100644 --- a/gfx/image.cpp +++ b/gfx/image.cpp @@ -1,5 +1,6 @@ #include "image.h" #include +#include #include #include @@ -13,7 +14,7 @@ Image::Image(const char * fileName, int flags) : width {}, height {}, numCompone numComponents = static_cast(nc); if (!bytes) { - throw std::runtime_error {std::string {"Unable to load image: "} + fileName}; + throw std::runtime_error {std::format("Unable to load image: {}", fileName)}; } data = {bytes, static_cast(width * height * numComponents)}; @@ -29,7 +30,8 @@ Image::Image(std::span buffer, int flags) numComponents = static_cast(nc); if (!bytes) { - throw std::runtime_error {"Unable to load image from memory buffer "}; + throw std::runtime_error {std::format("Unable to load image from memory buffer @ {} ({} bytes)", + static_cast(buffer.data()), buffer.size_bytes())}; } data = {bytes, static_cast(width * height * numComponents)}; -- cgit v1.2.3