bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitexception.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) Riccardo Ostani - All Rights Reserved.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef BITEXCEPTION_HPP
11#define BITEXCEPTION_HPP
12
13#include "bitdefines.hpp"
14#include "bittypes.hpp"
15#include "bitwindows.hpp"
16
17#include <utility>
18#include <vector>
19#include <string>
20#include <system_error>
21
22namespace bit7z {
23
29
34
42auto make_hresult_code( HRESULT res ) noexcept -> std::error_code;
43
49auto lastErrorCode() noexcept -> std::error_code;
50
54class BitException final : public std::system_error {
55 public:
56#ifdef _WIN32
57 using native_code_type = HRESULT;
58#else
59 using native_code_type = int;
60#endif
61
69 explicit BitException( const char* message, std::error_code code, FailedFiles&& files = {} );
70
78 BitException( const char* message, std::error_code code, tstring&& file );
79
87 BitException( const char* message, std::error_code code, const tstring& file );
88
95 explicit BitException( const std::string& message, std::error_code code );
96
101 BIT7Z_NODISCARD auto nativeCode() const noexcept -> native_code_type;
102
106 BIT7Z_NODISCARD auto hresultCode() const noexcept -> HRESULT;
107
111 BIT7Z_NODISCARD auto posixCode() const noexcept -> int;
112
117 BIT7Z_NODISCARD auto failedFiles() const noexcept -> const FailedFiles&;
118
119 private:
120 FailedFiles mFailedFiles;
121};
122
123} // namespace bit7z
124
125#endif // BITEXCEPTION_HPP
auto hresultCode() const noexcept -> HRESULT
auto posixCode() const noexcept -> int
BitException(const std::string &message, std::error_code code)
Constructs a BitException object with the given message.
auto failedFiles() const noexcept -> const FailedFiles &
auto nativeCode() const noexcept -> native_code_type
BitException(const char *message, std::error_code code, FailedFiles &&files={})
Constructs a BitException object with the given message, and the specific files that failed.
BitException(const char *message, std::error_code code, const tstring &file)
Constructs a BitException object with the given message, and the specific file that failed.
BitException(const char *message, std::error_code code, tstring &&file)
Constructs a BitException object with the given message, and the specific file that failed.
T code(T... args)
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
std::pair< tstring, std::error_code > FailedFile
An alias for a pair holding: 1) the path or identifier of a file (tstring) 2) the error that occurred...
Definition bitexception.hpp:28
auto lastErrorCode() noexcept -> std::error_code
Returns a std::error_code corresponding to the last system error that occurred.
std::basic_string< tchar > tstring
Definition bittypes.hpp:104
auto make_hresult_code(HRESULT res) noexcept -> std::error_code
Creates a std::error_code from the given HRESULT value.
std::vector< FailedFile > FailedFiles
An alias for a sequence of FailedFile entries.
Definition bitexception.hpp:33
T system_error(T... args)