bit7z 4.0.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) 2014-2023 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 <vector>
14#include <system_error>
15
16#include "bitdefines.hpp"
17#include "bittypes.hpp"
18#include "bitwindows.hpp"
19
20namespace bit7z {
21
24
25auto make_hresult_code( HRESULT res ) noexcept -> std::error_code;
26
27auto last_error_code() noexcept -> std::error_code;
28
32class BitException final : public system_error {
33 public:
34#ifdef _WIN32
35 using native_code_type = HRESULT;
36#else
37 using native_code_type = int;
38#endif
39
47 explicit BitException( const char* message, std::error_code code, FailedFiles&& files = {} );
48
56 BitException( const char* message, std::error_code code, tstring&& file );
57
65 BitException( const char* message, std::error_code code, const tstring& file );
66
73 explicit BitException( const std::string& message, std::error_code code );
74
79 BIT7Z_NODISCARD auto nativeCode() const noexcept -> native_code_type;
80
84 BIT7Z_NODISCARD auto hresultCode() const noexcept -> HRESULT;
85
89 BIT7Z_NODISCARD auto posixCode() const noexcept -> int;
90
95 BIT7Z_NODISCARD auto failedFiles() const noexcept -> const FailedFiles&;
96
97 private:
98 FailedFiles mFailedFiles;
99};
100
101} // namespace bit7z
102
103#endif // BITEXCEPTION_HPP
The BitException class represents a generic exception thrown from the bit7z classes.
Definition bitexception.hpp:32
BitException(const std::string &message, std::error_code code)
Constructs a BitException object with the given message.
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.
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30