Split error macro into two versions (format vs non-formating) to allow format checking at compile-time

This commit is contained in:
SirLynix
2023-11-02 15:18:03 +01:00
parent 8fb53f467b
commit 4b8a475bbd
133 changed files with 570 additions and 557 deletions

View File

@@ -101,7 +101,7 @@ namespace Nz
{
Stream* stream = static_cast<Stream*>(userdata);
if (stream->Write(data, size) != static_cast<std::size_t>(size))
throw std::runtime_error("Failed to write to stream");
throw std::runtime_error("failed to write to stream");
}
bool SaveBMP(const Image& image, const ImageParams& parameters, Stream& stream)
@@ -140,7 +140,7 @@ namespace Nz
long long imageQuality = parameters.custom.GetIntegerParameter("JPEGQuality").GetValueOr(100);
if (imageQuality <= 0 || imageQuality > 100)
{
NazaraError("NativeJPEGSaver_Quality value ({0}) does not fit in bounds ]0, 100], clamping...", imageQuality);
NazaraErrorFmt("NativeJPEGSaver_Quality value ({0}) does not fit in bounds ]0, 100], clamping...", imageQuality);
imageQuality = Nz::Clamp(imageQuality, 1LL, 100LL);
}
@@ -162,13 +162,13 @@ namespace Nz
int componentCount = ConvertToFloatFormat(tempImage);
if (componentCount == 0)
{
NazaraError("Failed to convert image to suitable format");
NazaraError("failed to convert image to suitable format");
return false;
}
if (!stbi_write_hdr_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, reinterpret_cast<const float*>(tempImage.GetConstPixels())))
{
NazaraError("Failed to write HDR to stream");
NazaraError("failed to write HDR to stream");
return false;
}
@@ -184,13 +184,13 @@ namespace Nz
int componentCount = ConvertToIntegerFormat(tempImage);
if (componentCount == 0)
{
NazaraError("Failed to convert image to suitable format");
NazaraError("failed to convert image to suitable format");
return false;
}
if (!stbi_write_png_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, tempImage.GetConstPixels(), 0))
{
NazaraError("Failed to write PNG to stream");
NazaraError("failed to write PNG to stream");
return false;
}
@@ -206,13 +206,13 @@ namespace Nz
int componentCount = ConvertToIntegerFormat(tempImage);
if (componentCount == 0)
{
NazaraError("Failed to convert image to suitable format");
NazaraError("failed to convert image to suitable format");
return false;
}
if (!stbi_write_tga_to_func(&WriteToStream, &stream, tempImage.GetWidth(), tempImage.GetHeight(), componentCount, tempImage.GetConstPixels()))
{
NazaraError("Failed to write TGA to stream");
NazaraError("failed to write TGA to stream");
return false;
}
@@ -241,14 +241,14 @@ namespace Nz
if (!image.IsValid())
{
NazaraError("Invalid image");
NazaraError("invalid image");
return false;
}
ImageType type = image.GetType();
if (type != ImageType::E1D && type != ImageType::E2D)
{
NazaraError("Image type {0:#x}) is not in a supported format", UnderlyingCast(type));
NazaraErrorFmt("Image type {0:#x}) is not in a supported format", UnderlyingCast(type));
return false;
}