Allow error message to be formatted
This commit is contained in:
committed by
Jérôme Leclercq
parent
25957c4b7f
commit
a741672a51
@@ -72,7 +72,7 @@ namespace Nz
|
||||
if (!config.allowDummyDevice)
|
||||
throw;
|
||||
|
||||
NazaraError(std::string("failed to open default OpenAL device: ") + e.what());
|
||||
NazaraError("failed to open default OpenAL device: {0}", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(wav.channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(wav.channels));
|
||||
NazaraError("unexpected channel count: {0}", wav.channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: " + Error::GetLastError());
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return Err(ResourceLoadingError::FailedToOpenFile);
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_decoder.channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(m_decoder.channels));
|
||||
NazaraError("unexpected channel count: {0}", m_decoder.channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(channelCount);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(channelCount));
|
||||
NazaraError("unexpected channel count: {0}", channelCount);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: " + Error::GetLastError());
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return Err(ResourceLoadingError::FailedToOpenFile);
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_channelCount);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(m_channelCount));
|
||||
NazaraError("unexpected channel count: {0}", m_channelCount);
|
||||
return Err(ResourceLoadingError::Unrecognized);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Nz
|
||||
|
||||
if (readBytes < 0)
|
||||
{
|
||||
NazaraError("an error occurred while reading file: " + VorbisErrToString(readBytes));
|
||||
NazaraError("an error occurred while reading file: {0}", VorbisErrToString(readBytes));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info->channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(info->channels));
|
||||
NazaraError("unexpected channel count: {0}", info->channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: " + Error::GetLastError());
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return Err(ResourceLoadingError::FailedToOpenFile);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info->channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(info->channels));
|
||||
NazaraError("unexpected channel count: {0}", info->channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(info.channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(info.channels));
|
||||
NazaraError("unexpected channel count: {0}", info.channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Nz
|
||||
std::unique_ptr<File> file = std::make_unique<File>();
|
||||
if (!file->Open(filePath, OpenMode::ReadOnly))
|
||||
{
|
||||
NazaraError("failed to open stream from file: " + Error::GetLastError());
|
||||
NazaraError("failed to open stream from file: {0}", Error::GetLastError());
|
||||
return Err(ResourceLoadingError::FailedToOpenFile);
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace Nz
|
||||
std::optional<AudioFormat> formatOpt = GuessAudioFormat(m_decoder.info.channels);
|
||||
if (!formatOpt)
|
||||
{
|
||||
NazaraError("unexpected channel count: " + std::to_string(m_decoder.info.channels));
|
||||
NazaraError("unexpected channel count: {0}", m_decoder.info.channels);
|
||||
return Err(ResourceLoadingError::Unsupported);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Nz
|
||||
|
||||
if (ALenum lastError = m_library.alGetError(); lastError != AL_NO_ERROR)
|
||||
{
|
||||
NazaraError("failed to reset OpenAL buffer: " + std::to_string(lastError));
|
||||
NazaraError("failed to reset OpenAL buffer: {0}", std::to_string(lastError));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,8 @@ namespace Nz
|
||||
|
||||
for (const char* libname : libs)
|
||||
{
|
||||
ErrorFlags disableError(ErrorMode::Silent, ~ErrorMode::ThrowException);
|
||||
|
||||
if (!m_library.Load(libname))
|
||||
continue;
|
||||
|
||||
@@ -84,6 +86,8 @@ namespace Nz
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
ErrorFlags disableSilent({}, ~ErrorMode::Silent);
|
||||
|
||||
NazaraWarning(std::string("failed to load ") + libname + ": " + e.what());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Nz
|
||||
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromFile(filePath, params);
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraError("Failed to load buffer from file (" + filePath.generic_u8string() + ')');
|
||||
NazaraError("Failed to load buffer from file ({0})", filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ namespace Nz
|
||||
std::shared_ptr<SoundBuffer> buffer = SoundBuffer::LoadFromMemory(data, size, params);
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraError("Failed to load buffer from memory (" + PointerToString(data) + ')');
|
||||
NazaraError("failed to load buffer from memory ({0})", PointerToString(data));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user