openPMD-api
ThrowError.hpp
1 /* Copyright 2022 Franz Poeschel
2  *
3  * This file is part of openPMD-api.
4  *
5  * openPMD-api is free software: you can redistribute it and/or modify
6  * it under the terms of of either the GNU General Public License or
7  * the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openPMD-api is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License and the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * and the GNU Lesser General Public License along with openPMD-api.
19  * If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 /*
23  * For objects that must not include Error.hpp but still need to throw errors.
24  * In some exotic compiler configurations (clang-6 with libc++),
25  * including Error.hpp into the ADIOS1 backend leads to incompatible error type
26  * symbols.
27  * So, use only the functions defined in here in the ADIOS1 backend.
28  * Definitions are in Error.cpp.
29  */
30 
31 #pragma once
32 
33 #include "openPMD/auxiliary/Export.hpp"
34 
35 #include <optional>
36 #include <string>
37 #include <vector>
38 
39 namespace openPMD::error
40 {
41 enum class AffectedObject
42 {
43  Attribute,
44  Dataset,
45  File,
46  Group,
47  Other
48 };
49 
50 enum class Reason
51 {
52  NotFound,
53  CannotRead,
54  UnexpectedContent,
55  Inaccessible,
56  Other
57 };
58 
59 [[noreturn]] OPENPMDAPI_EXPORT void
60 throwBackendConfigSchema(std::vector<std::string> jsonPath, std::string what);
61 
62 [[noreturn]] OPENPMDAPI_EXPORT void
63 throwOperationUnsupportedInBackend(std::string backend, std::string what);
64 
65 [[noreturn]] OPENPMDAPI_EXPORT void throwReadError(
66  AffectedObject affectedObject,
67  Reason reason_in,
68  std::optional<std::string> backend,
69  std::string description_in);
70 
71 [[noreturn]] OPENPMDAPI_EXPORT void
72 throwNoSuchAttribute(std::string attributeName);
73 } // namespace openPMD::error
Definition: Error.cpp:12