2018-08-23 12:31:36 +02:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_FS_ERROR_H
|
|
|
|
|
2019-03-17 01:21:42 +01:00
|
|
|
namespace ircd::fs
|
2018-08-23 12:31:36 +02:00
|
|
|
{
|
2019-03-17 01:21:42 +01:00
|
|
|
struct error; // does not participate in ircd::exception hierarchy
|
|
|
|
}
|
2018-08-23 12:31:36 +02:00
|
|
|
|
2019-03-17 01:21:42 +01:00
|
|
|
namespace ircd
|
|
|
|
{
|
2022-07-05 21:09:52 +02:00
|
|
|
string_view string(const mutable_buffer &, const std::filesystem::filesystem_error &);
|
|
|
|
std::string string(const std::filesystem::filesystem_error &);
|
2018-08-23 12:31:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
struct ircd::fs::error
|
2022-07-05 21:09:52 +02:00
|
|
|
:std::filesystem::filesystem_error
|
2018-08-23 12:31:36 +02:00
|
|
|
{
|
2022-07-05 21:09:52 +02:00
|
|
|
static constexpr size_t max_len {4096};
|
2018-08-23 12:31:36 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2022-07-05 21:09:52 +02:00
|
|
|
[[clang::internal_linkage]]
|
|
|
|
error(const std::filesystem::filesystem_error &e,
|
2018-12-24 22:34:23 +01:00
|
|
|
const string_view &fmt,
|
2018-08-23 12:31:36 +02:00
|
|
|
args&&...);
|
|
|
|
|
|
|
|
template<class... args>
|
2022-07-05 21:09:52 +02:00
|
|
|
[[clang::internal_linkage]]
|
2019-03-17 01:21:42 +01:00
|
|
|
error(const std::error_code &e,
|
2018-12-24 22:34:23 +01:00
|
|
|
const string_view &fmt,
|
2018-08-23 12:31:36 +02:00
|
|
|
args&&...);
|
|
|
|
|
2022-07-05 21:09:52 +02:00
|
|
|
error(const std::error_code &e, const string_view &fmt);
|
|
|
|
error(const std::filesystem::filesystem_error &e, const string_view &fmt);
|
|
|
|
error(const std::filesystem::filesystem_error &e);
|
|
|
|
~error() noexcept;
|
2018-08-23 12:31:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class... args>
|
2022-07-05 21:09:52 +02:00
|
|
|
[[gnu::noinline, gnu::visibility("internal")]]
|
|
|
|
ircd::fs::error::error(const std::filesystem::filesystem_error &e,
|
2018-12-24 22:34:23 +01:00
|
|
|
const string_view &fmt,
|
2018-08-25 00:44:00 +02:00
|
|
|
args&&... a)
|
2022-07-05 21:09:52 +02:00
|
|
|
:std::filesystem::filesystem_error
|
2018-08-23 12:31:36 +02:00
|
|
|
{
|
2022-07-05 21:09:52 +02:00
|
|
|
fmt::snstringf{max_len, fmt, std::forward<args>(a)...},
|
|
|
|
e.path1(),
|
|
|
|
e.path2(),
|
|
|
|
e.code(),
|
2018-08-23 12:31:36 +02:00
|
|
|
}
|
2018-12-16 05:12:39 +01:00
|
|
|
{}
|
2018-08-23 12:31:36 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2022-07-05 21:09:52 +02:00
|
|
|
[[gnu::noinline, gnu::visibility("internal")]]
|
2018-08-23 12:31:36 +02:00
|
|
|
ircd::fs::error::error(const std::error_code &e,
|
2018-12-24 22:34:23 +01:00
|
|
|
const string_view &fmt,
|
2018-08-25 00:44:00 +02:00
|
|
|
args&&... a)
|
2022-07-05 21:09:52 +02:00
|
|
|
:std::filesystem::filesystem_error
|
2018-08-23 12:31:36 +02:00
|
|
|
{
|
2022-07-05 21:09:52 +02:00
|
|
|
fmt::snstringf{max_len, fmt, std::forward<args>(a)...},
|
|
|
|
e,
|
|
|
|
}
|
2018-12-16 05:12:39 +01:00
|
|
|
{}
|