lib/fmt/RuntimeError: new library

Replacing FormatRuntimeError().
This commit is contained in:
Max Kellermann
2022-11-28 21:58:21 +01:00
parent 45b13fc2a6
commit fa58db798b
105 changed files with 551 additions and 502 deletions

View File

@@ -27,7 +27,8 @@
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "fs/Path.hxx"
#include "util/RuntimeError.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "lib/fmt/RuntimeError.hxx"
#include "util/StringCompare.hxx"
#include "util/UTF8.hxx"
@@ -46,8 +47,8 @@ struct Iso9660 {
explicit Iso9660(Path path)
:iso(iso9660_open(path.c_str())) {
if (iso == nullptr)
throw FormatRuntimeError("Failed to open ISO9660 file %s",
path.c_str());
throw FmtRuntimeError("Failed to open ISO9660 file {}",
path);
}
~Iso9660() noexcept {
@@ -238,8 +239,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
{
auto statbuf = iso9660_ifs_stat_translate(iso->iso, pathname);
if (statbuf == nullptr)
throw FormatRuntimeError("not found in the ISO file: %s",
pathname);
throw FmtRuntimeError("not found in the ISO file: {}",
pathname);
const lsn_t lsn = statbuf->lsn;
const offset_type size = statbuf->size;

View File

@@ -26,25 +26,24 @@
#include "../ArchiveFile.hxx"
#include "../ArchiveVisitor.hxx"
#include "input/InputStream.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "lib/fmt/RuntimeError.hxx"
#include "fs/Path.hxx"
#include "lib/fmt/SystemError.hxx"
#include "util/RuntimeError.hxx"
#include "util/UTF8.hxx"
#include <zzip/zzip.h>
#include <utility>
#include <cinttypes> /* for PRIoffset (PRIu64) */
struct ZzipDir {
ZZIP_DIR *const dir;
explicit ZzipDir(Path path)
:dir(zzip_dir_open(path.c_str(), nullptr)) {
if (dir == nullptr)
throw FormatRuntimeError("Failed to open ZIP file %s",
path.c_str());
throw FmtRuntimeError("Failed to open ZIP file {}",
path);
}
~ZzipDir() noexcept {
@@ -140,9 +139,9 @@ ZzipArchiveFile::OpenStream(const char *pathname,
pathname);
default:
throw FormatRuntimeError("Failed to open '%s' in ZIP file: %s",
pathname,
zzip_strerror(error));
throw FmtRuntimeError("Failed to open '{}' in ZIP file: {}",
pathname,
zzip_strerror(error));
}
}
@@ -161,9 +160,8 @@ ZzipInputStream::Read(std::unique_lock<Mutex> &, void *ptr, size_t read_size)
throw std::runtime_error("zzip_file_read() has failed");
if (nbytes == 0 && !IsEOF())
throw FormatRuntimeError("Unexpected end of file %s"
" at %" PRIoffset " of %" PRIoffset,
GetURI(), GetOffset(), GetSize());
throw FmtRuntimeError("Unexpected end of file {} at {} of {}",
GetURI(), GetOffset(), GetSize());
offset = zzip_tell(file);
return nbytes;