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

@@ -107,7 +107,7 @@ aiFile* StreamOpener(aiFileIO* fileIO, const char* filePath, const char* openMod
}
else
{
NazaraError("unhandled/invalid openmode: {0} for file {1}", openMode, filePath);
NazaraErrorFmt("unhandled/invalid openmode: {0} for file {1}", openMode, filePath);
return nullptr;
}

View File

@@ -157,7 +157,7 @@ bool FindSkeletonRoot(SceneInfo& sceneInfo, const aiNode* node)
auto range = sceneInfo.nodeByName.equal_range(node->mName.C_Str());
if (std::distance(range.first, range.second) != 1)
{
NazaraError("failed to identify skeleton root node: {0} node(s) matched", std::distance(range.first, range.second));
NazaraErrorFmt("failed to identify skeleton root node: {0} node(s) matched", std::distance(range.first, range.second));
return false;
}
@@ -265,7 +265,7 @@ Nz::Result<std::shared_ptr<Nz::Animation>, Nz::ResourceLoadingError> LoadAnimati
if (!scene)
{
NazaraError("Assimp failed to import file: {0}", aiGetErrorString());
NazaraErrorFmt("Assimp failed to import file: {0}", aiGetErrorString());
return Nz::Err(Nz::ResourceLoadingError::DecodingError);
}
@@ -308,7 +308,7 @@ Nz::Result<std::shared_ptr<Nz::Animation>, Nz::ResourceLoadingError> LoadAnimati
std::size_t jointIndex = parameters.skeleton->GetJointIndex(nodeAnim->mNodeName.C_Str());
if (jointIndex == Nz::Skeleton::InvalidJointIndex)
{
NazaraError("animation references joint {0} which is not part of the skeleton", nodeAnim->mNodeName.C_Str());
NazaraErrorFmt("animation references joint {0} which is not part of the skeleton", nodeAnim->mNodeName.C_Str());
continue;
}
@@ -815,7 +815,7 @@ Nz::Result<std::shared_ptr<Nz::Mesh>, Nz::ResourceLoadingError> LoadMesh(Nz::Str
if (!scene)
{
NazaraError("Assimp failed to import file: {0}", aiGetErrorString());
NazaraErrorFmt("Assimp failed to import file: {0}", aiGetErrorString());
return Nz::Err(Nz::ResourceLoadingError::DecodingError);
}

View File

@@ -98,13 +98,13 @@ namespace
if (int errCode = avformat_open_input(&m_formatContext, "", nullptr, nullptr); errCode != 0)
{
NazaraError("failed to open input: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to open input: {0}", ErrorToString(errCode));
return Nz::Err(Nz::ResourceLoadingError::Unrecognized);
}
if (int errCode = avformat_find_stream_info(m_formatContext, nullptr); errCode != 0)
{
NazaraError("failed to find stream info: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to find stream info: {0}", ErrorToString(errCode));
return Nz::Err(Nz::ResourceLoadingError::Unrecognized);
}
@@ -150,7 +150,7 @@ namespace
return false;
}
NazaraError("failed to read frame: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to read frame: {0}", ErrorToString(errCode));
return false;
}
@@ -159,7 +159,7 @@ namespace
if (int errCode = avcodec_send_packet(m_codecContext, &packet); errCode < 0)
{
NazaraError("failed to send packet: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to send packet: {0}", ErrorToString(errCode));
return false;
}
@@ -168,7 +168,7 @@ namespace
if (errCode == AVERROR(EAGAIN))
continue;
NazaraError("failed to receive frame: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to receive frame: {0}", ErrorToString(errCode));
return false;
}
@@ -236,13 +236,13 @@ namespace
if (int errCode = avcodec_parameters_to_context(m_codecContext, codecParameters); errCode < 0)
{
NazaraError("failed to copy codec params to codec context: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to copy codec params to codec context: {0}", ErrorToString(errCode));
return Nz::Err(Nz::ResourceLoadingError::Internal);
}
if (int errCode = avcodec_open2(m_codecContext, m_codec, nullptr); errCode < 0)
{
NazaraError("could not open codec: {0}", ErrorToString(errCode));
NazaraErrorFmt("could not open codec: {0}", ErrorToString(errCode));
return Nz::Err(Nz::ResourceLoadingError::Internal);
}
@@ -260,7 +260,7 @@ namespace
if (int errCode = av_frame_get_buffer(m_rgbaFrame, 0); errCode < 0)
{
NazaraError("failed to open input: {0}", ErrorToString(errCode));
NazaraErrorFmt("failed to open input: {0}", ErrorToString(errCode));
return Nz::Err(Nz::ResourceLoadingError::Internal);
}
@@ -286,7 +286,7 @@ namespace
std::unique_ptr<Nz::File> file = std::make_unique<Nz::File>();
if (!file->Open(filePath, Nz::OpenMode::ReadOnly))
{
NazaraError("failed to open stream from file: {0}", Nz::Error::GetLastError());
NazaraErrorFmt("failed to open stream from file: {0}", Nz::Error::GetLastError());
return false;
}
m_ownedStream = std::move(file);