Skip to content

Commit b62fd8e

Browse files
committed
changing exception type in MappingHandler
1 parent e6babd2 commit b62fd8e

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

libtokamap/TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
- [x] ~~Replace gsl::span with std::span~~
1717
- [ ] Handle mismatch of request data type and returned data type, i.e. type conversions?
1818
- [ ] Check returned data against expected rank
19+
- [ ] Add JSON schema files into repo (from IMAS MASTU mapping)
20+
- [ ] Validate JSON mappings on read

libtokamap/examples/simple_mapper/src/json_data_source.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@
88
#include <filesystem>
99
#include <fstream>
1010
#include <libtokamap.hpp>
11-
#include "exceptions/exceptions.hpp"
1211
#include <nlohmann/json.hpp>
13-
#include <stdexcept>
1412
#include <string>
1513
#include <vector>
1614

17-
#include "map_types/map_arguments.hpp"
18-
#include "utils/algorithm.hpp"
19-
2015
using namespace std::string_literals;
2116

2217
namespace

libtokamap/examples/simple_mapper/src/json_data_source.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1+
#include <filesystem>
12
#include <libtokamap.hpp>
23
#include <nlohmann/json.hpp>
3-
#include <stdexcept>
4-
#include "exceptions/exceptions.hpp"
54
#include <string>
65
#include <unordered_map>
76
#include <utility>
8-
#include <filesystem>
97

108
class JSONDataSource : public libtokamap::DataSource
119
{
1210
public:
13-
explicit JSONDataSource(std::filesystem::path data_root) : m_data_root{std::move(data_root)} {
11+
explicit JSONDataSource(std::filesystem::path data_root) : m_data_root{std::move(data_root)}
12+
{
1413
if (!std::filesystem::exists(m_data_root)) {
1514
throw libtokamap::FileError{"data root does not exist"};
1615
}

libtokamap/examples/simple_mapper/src/simple_mapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <algorithm>
12
#include <bit>
23
#include <cstddef>
34
#include <cstdint>
@@ -10,7 +11,6 @@
1011
#include <string>
1112
#include <typeindex>
1213
#include <utility>
13-
#include <algorithm>
1414

1515
#include "json_data_source.hpp"
1616

libtokamap/include/libtokamap.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <map_types/expr_mapping.hpp> // IWYU pragma: export.
88
#include <map_types/map_arguments.hpp> // IWYU pragma: export.
99
#include <map_types/value_mapping.hpp> // IWYU pragma: export.
10+
#include <utils/algorithm.hpp> // IWYU pragma: export.
1011
#include <utils/indices.hpp> // IWYU pragma: export.
1112
#include <utils/ram_cache.hpp> // IWYU pragma: export.
1213
#include <utils/scale_offset.hpp> // IWYU pragma: export.

libtokamap/src/handlers/mapping_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ libtokamap::TypedDataArray libtokamap::MappingHandler::map(const std::string& ma
200200
const auto maybe_mappings = read_mappings(machine_string, ids_name, extra_attributes);
201201

202202
if (!maybe_mappings) {
203-
throw libtokamap::MappingError{"no mappings found for machine '" + machine_string + "' and IDS '" + ids_name +
204-
"'"};
203+
auto msg = "no mappings found for machine '" + machine_string + "' and IDS '" + ids_name + "'";
204+
throw libtokamap::ParameterError{msg};
205205
}
206206

207207
const auto& [attributes, mappings] = maybe_mappings.value();

0 commit comments

Comments
 (0)