1#ifndef SOURCEMETA_CORE_IO_ERROR_H_
2#define SOURCEMETA_CORE_IO_ERROR_H_
4#ifndef SOURCEMETA_CORE_IO_EXPORT
5#include <sourcemeta/core/io_export.h>
14namespace sourcemeta::core {
20#pragma warning(disable : 4251 4275)
29 : path_{std::move(
path)}, message_{message} {}
30 FileViewError(std::filesystem::path path, std::string message) =
delete;
31 FileViewError(std::filesystem::path path, std::string &&message) =
delete;
32 FileViewError(std::filesystem::path path, std::string_view message) =
delete;
34 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
35 return this->message_;
39 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
44 std::filesystem::path path_;
55 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
56 return "File not found";
60 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
65 std::filesystem::path path_;
75 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
76 return "Permission denied";
80 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
85 std::filesystem::path path_;
95 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
96 return "Expected a file but got a directory";
100 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
105 std::filesystem::path path_;
115 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
116 return "Expected a directory but got a file";
120 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
125 std::filesystem::path path_;
131 :
public std::exception {
135 : path_{std::move(
path)} {}
137 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
138 return "File already exists";
142 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
147 std::filesystem::path path_;
155 [[nodiscard]]
auto what()
const noexcept ->
const char *
override {
156 return "Read past the end of the underlying data";
164 [[nodiscard]]
auto what()
const noexcept ->
const char *
override {
165 return "Failed to write to stream";
170#pragma warning(default : 4251 4275)
IOFileNotFoundError(std::filesystem::path path)
Construct the error given the offending path.
Definition io_error.h:53
IOFilePermissionError(std::filesystem::path path)
Construct the error given the offending path.
Definition io_error.h:73
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:39
IOIsADirectoryError(std::filesystem::path path)
Construct the error given the offending path.
Definition io_error.h:93
FileViewError(std::filesystem::path path, const char *message)
Construct the error given the offending path and a message.
Definition io_error.h:28
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:60
IOFileAlreadyExistsError(std::filesystem::path path)
Construct the error given the offending path.
Definition io_error.h:134
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:100
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:142
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:120
auto path() const noexcept -> const std::filesystem::path &
The offending path.
Definition io_error.h:80
IONotADirectoryError(std::filesystem::path path)
Construct the error given the offending path.
Definition io_error.h:113