system/FmtError: new library
Replaces the Format*() functions in system/Error.hxx.
This commit is contained in:
@@ -20,9 +20,11 @@
|
||||
#include "FifoOutputPlugin.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "../Timer.hxx"
|
||||
#include "lib/fmt/PathFormatter.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/FileInfo.hxx"
|
||||
#include "system/FmtError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -91,7 +93,7 @@ inline void
|
||||
FifoOutput::Delete()
|
||||
{
|
||||
FmtDebug(fifo_output_domain,
|
||||
"Removing FIFO \"{}\"", path_utf8);
|
||||
"Removing FIFO \"{}\"", path);
|
||||
|
||||
try {
|
||||
RemoveFile(path);
|
||||
@@ -125,8 +127,7 @@ inline void
|
||||
FifoOutput::Create()
|
||||
{
|
||||
if (!MakeFifo(path, 0666))
|
||||
throw FormatErrno("Couldn't create FIFO \"%s\"",
|
||||
path_utf8.c_str());
|
||||
throw FmtErrno("Couldn't create FIFO \"{}\"", path);
|
||||
|
||||
created = true;
|
||||
}
|
||||
@@ -142,8 +143,7 @@ FifoOutput::Check()
|
||||
return;
|
||||
}
|
||||
|
||||
throw FormatErrno("Failed to stat FIFO \"%s\"",
|
||||
path_utf8.c_str());
|
||||
throw FmtErrno("Failed to stat FIFO \"{}\"", path);
|
||||
}
|
||||
|
||||
if (!S_ISFIFO(st.st_mode))
|
||||
@@ -158,13 +158,12 @@ try {
|
||||
|
||||
input = OpenFile(path, O_RDONLY|O_NONBLOCK|O_BINARY, 0).Steal();
|
||||
if (input < 0)
|
||||
throw FormatErrno("Could not open FIFO \"%s\" for reading",
|
||||
path_utf8.c_str());
|
||||
throw FmtErrno("Could not open FIFO \"{}\" for reading",
|
||||
path);
|
||||
|
||||
output = OpenFile(path, O_WRONLY|O_NONBLOCK|O_BINARY, 0).Steal();
|
||||
if (output < 0)
|
||||
throw FormatErrno("Could not open FIFO \"%s\" for writing",
|
||||
path_utf8.c_str());
|
||||
throw FmtErrno("Could not open FIFO \"{}\" for writing");
|
||||
} catch (...) {
|
||||
CloseFifo();
|
||||
throw;
|
||||
@@ -196,7 +195,7 @@ FifoOutput::Cancel() noexcept
|
||||
if (bytes < 0 && errno != EAGAIN) {
|
||||
FmtError(fifo_output_domain,
|
||||
"Flush of FIFO \"{}\" failed: {}",
|
||||
path_utf8, strerror(errno));
|
||||
path, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,8 +229,7 @@ FifoOutput::Play(std::span<const std::byte> src)
|
||||
continue;
|
||||
}
|
||||
|
||||
throw FormatErrno("Failed to write to FIFO %s",
|
||||
path_utf8.c_str());
|
||||
throw FmtErrno("Failed to write to FIFO {}", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "mixer/plugins/OssMixerPlugin.hxx"
|
||||
#include "pcm/Export.hxx"
|
||||
#include "io/UniqueFileDescriptor.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "system/FmtError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/ByteOrder.hxx"
|
||||
#include "util/Manual.hxx"
|
||||
@@ -643,7 +643,7 @@ try {
|
||||
assert(!fd.IsDefined());
|
||||
|
||||
if (!fd.Open(device, O_WRONLY))
|
||||
throw FormatErrno("Error opening OSS device \"%s\"", device);
|
||||
throw FmtErrno("Error opening OSS device \"{}\"", device);
|
||||
|
||||
OssIoctlExact(fd, SNDCTL_DSP_CHANNELS, effective_channels,
|
||||
"Failed to set channel count");
|
||||
@@ -660,7 +660,7 @@ void
|
||||
OssOutput::Open(AudioFormat &_audio_format)
|
||||
try {
|
||||
if (!fd.Open(device, O_WRONLY))
|
||||
throw FormatErrno("Error opening OSS device \"%s\"", device);
|
||||
throw FmtErrno("Error opening OSS device \"{}\"", device);
|
||||
|
||||
SetupOrDop(_audio_format);
|
||||
} catch (...) {
|
||||
@@ -698,7 +698,7 @@ OssOutput::Play(std::span<const std::byte> src)
|
||||
return pcm_export->CalcInputSize(ret);
|
||||
|
||||
if (ret < 0 && errno != EINTR)
|
||||
throw FormatErrno("Write error on %s", device);
|
||||
throw FmtErrno("Write error on {}", device);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "PipeOutputPlugin.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "system/FmtError.hxx"
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
@@ -61,7 +61,7 @@ PipeOutput::Open([[maybe_unused]] AudioFormat &audio_format)
|
||||
{
|
||||
fh = popen(cmd.c_str(), "w");
|
||||
if (fh == nullptr)
|
||||
throw FormatErrno("Error opening pipe \"%s\"", cmd.c_str());
|
||||
throw FmtErrno("Error opening pipe \"{}\"", cmd);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "SolarisOutputPlugin.hxx"
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "io/FileDescriptor.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "system/FmtError.hxx"
|
||||
|
||||
#include <cerrno>
|
||||
|
||||
@@ -100,8 +100,7 @@ SolarisOutput::Open(AudioFormat &audio_format)
|
||||
/* open the device in non-blocking mode */
|
||||
|
||||
if (!fd.Open(device, O_WRONLY|O_NONBLOCK))
|
||||
throw FormatErrno("Failed to open %s",
|
||||
device);
|
||||
throw FmtErrno("Failed to open {}", device);
|
||||
|
||||
/* restore blocking mode */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user