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

@@ -20,7 +20,7 @@ namespace Nz
m_buffer(nullptr)
{
if (!Map(buffer, offset, length))
NazaraError("Failed to map buffer"); ///TODO: Unexpected
NazaraError("failed to map buffer"); ///TODO: Unexpected
}
template<typename T>
@@ -51,7 +51,7 @@ namespace Nz
m_ptr = buffer.Map(offset, length);
if (!m_ptr)
{
NazaraError("Failed to map buffer"); ///TODO: Unexpected
NazaraError("failed to map buffer"); ///TODO: Unexpected
return false;
}

View File

@@ -53,7 +53,7 @@ namespace Nz
inline void MTLParser::Error(const std::string& message)
{
NazaraError("{0} at line #{1}", message, m_lineCount);
NazaraErrorFmt("{0} at line #{1}", message, m_lineCount);
}
inline void MTLParser::Flush() const
@@ -64,7 +64,7 @@ namespace Nz
inline void MTLParser::Warning(const std::string& message)
{
NazaraWarning("{0} at line #{1}", message, m_lineCount);
NazaraWarningFmt("{0} at line #{1}", message, m_lineCount);
}
inline void MTLParser::UnrecognizedLine(bool error)

View File

@@ -153,7 +153,7 @@ namespace Nz
inline void OBJParser::Error(const std::string& message)
{
NazaraError("{0} at line #{1}", message, m_lineCount);
NazaraErrorFmt("{0} at line #{1}", message, m_lineCount);
}
inline void OBJParser::Flush() const
@@ -164,7 +164,7 @@ namespace Nz
inline void OBJParser::Warning(const std::string& message)
{
NazaraWarning("{0} at line #{1}", message, m_lineCount);
NazaraWarningFmt("{0} at line #{1}", message, m_lineCount);
}
inline bool OBJParser::UnrecognizedLine(bool error)
@@ -180,7 +180,7 @@ namespace Nz
if (m_errorCount > 10 && (m_errorCount * 100 / m_lineCount) > 50)
{
NazaraError("Aborting parsing because of error percentage");
NazaraError("aborting parsing because of error percentage");
return false; //< Abort parsing if error percentage is too high
}

View File

@@ -159,7 +159,7 @@ namespace Nz
return m_position;
}
NazaraError("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
NazaraErrorFmt("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
return Vector3f();
}
@@ -181,7 +181,7 @@ namespace Nz
return m_rotation;
}
NazaraError("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
NazaraErrorFmt("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
return Quaternionf();
}
@@ -197,7 +197,7 @@ namespace Nz
return m_scale;
}
NazaraError("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
NazaraErrorFmt("Coordinate system out of enum ({0:#x})", UnderlyingCast(coordSys));
return Vector3f();
}

View File

@@ -156,7 +156,7 @@ namespace Nz
return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormat::DXT1) ? 8 : 16)) * depth;
default:
NazaraError("Unsupported format");
NazaraError("unsupported format");
return 0;
}
}
@@ -175,13 +175,13 @@ namespace Nz
#if NAZARA_UTILITY_SAFE
if (IsCompressed(srcFormat))
{
NazaraError("Cannot convert single pixel from compressed format");
NazaraError("cannot convert single pixel from compressed format");
return false;
}
if (IsCompressed(dstFormat))
{
NazaraError("Cannot convert single pixel to compressed format");
NazaraError("cannot convert single pixel to compressed format");
return false;
}
#endif
@@ -200,13 +200,13 @@ namespace Nz
ConvertFunction func = s_convertFunctions[srcFormat][dstFormat];
if (!func)
{
NazaraError("pixel format conversion from {0} to {1} is not supported", GetName(srcFormat), GetName(dstFormat));
NazaraErrorFmt("pixel format conversion from {0} to {1} is not supported", GetName(srcFormat), GetName(dstFormat));
return false;
}
if (!func(reinterpret_cast<const UInt8*>(start), reinterpret_cast<const UInt8*>(end), reinterpret_cast<UInt8*>(dst)))
{
NazaraError("pixel format conversion from {0} to {1} failed", GetName(srcFormat), GetName(dstFormat));
NazaraErrorFmt("pixel format conversion from {0} to {1} failed", GetName(srcFormat), GetName(dstFormat));
return false;
}