Skip to content

Commit 822f6ea

Browse files
Remove the noexcept from the write process
1 parent b16b36f commit 822f6ea

33 files changed

Lines changed: 65 additions & 88 deletions

include/rfl/avro/Writer.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010
#include <string_view>
1111
#include <type_traits>
1212

13-
#include "../Bytestring.hpp"
14-
#include "../Timestamp.hpp"
15-
#include "../Vectorstring.hpp"
1613
#include "../always_false.hpp"
1714
#include "../common.hpp"
1815
#include "../concepts.hpp"
1916
#include "../internal/is_literal.hpp"
20-
#include "../internal/is_validator.hpp"
21-
#include "../patterns.hpp"
2217

2318
namespace rfl::avro {
2419

@@ -140,7 +135,7 @@ class RFL_API Writer {
140135
avro_value_t new_value;
141136
int result = avro_value_append(&_parent->val_, &new_value, nullptr);
142137
if (result != 0) {
143-
throw std::runtime_error(std::string(__FUNCTION__) + " error(" +
138+
throw std::runtime_error("Error adding value to array: error(" +
144139
std::to_string(result) +
145140
"): " + avro_strerror());
146141
}
@@ -155,7 +150,7 @@ class RFL_API Writer {
155150
int result = avro_value_add(&_parent->val_, _name.data(), &new_value,
156151
nullptr, nullptr);
157152
if (result != 0) {
158-
throw std::runtime_error(std::string(__FUNCTION__) + " error(" +
153+
throw std::runtime_error("Error adding value to map: error(" +
159154
std::to_string(result) +
160155
"): " + avro_strerror());
161156
}
@@ -171,7 +166,7 @@ class RFL_API Writer {
171166
int result = avro_value_get_by_name(&_parent->val_, _name.data(),
172167
&new_value, nullptr);
173168
if (result != 0) {
174-
throw std::runtime_error(std::string(__FUNCTION__) + " error(" +
169+
throw std::runtime_error("Error adding value to object: error(" +
175170
std::to_string(result) +
176171
"): " + avro_strerror());
177172
}
@@ -183,7 +178,7 @@ class RFL_API Writer {
183178
OutputVarType add_value_to_union(const size_t _index, const T& _var,
184179
OutputUnionType* _parent) const {
185180
if (_index > static_cast<size_t>(INT_MAX)) {
186-
throw std::runtime_error(std::string(__FUNCTION__) + " index error");
181+
throw std::runtime_error("Error adding value to unions: Index error");
187182
}
188183
avro_value_t new_value;
189184
int result = avro_value_set_branch(&_parent->val_, static_cast<int>(_index),

include/rfl/avro/schema/Type.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <string>
77

88
#include "../../Literal.hpp"
9-
// #include "../../Object.hpp"
109
#include "../../Ref.hpp"
1110
#include "../../Rename.hpp"
1211
#include "../../Variant.hpp"

include/rfl/avro/to_schema.hpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@
33

44
#include <string>
55

6-
//#include "../Literal.hpp"
76
#include "../Processors.hpp"
8-
//#include "../Variant.hpp"
9-
//#include "../json.hpp"
10-
//#include "../parsing/schema/Type.hpp"
11-
//#include "../parsing/schema/ValidationType.hpp"
7+
#include "../common.hpp"
128
#include "../parsing/schema/make.hpp"
139
#include "Reader.hpp"
1410
#include "Schema.hpp"
1511
#include "Writer.hpp"
16-
//#include "schema/Type.hpp"
17-
#include "../common.hpp"
1812

1913
namespace rfl::avro {
2014

include/rfl/parsing/CustomParser.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ struct CustomParser {
3939
}
4040

4141
template <class P>
42-
static auto write(const W& _w, const OriginalClass& _p,
43-
const P& _parent) noexcept {
42+
static auto write(const W& _w, const OriginalClass& _p, const P& _parent) {
4443
Parser<R, W, CustomParserHelperStruct, ProcessorsType>::write(
4544
_w, HelperStruct::from_class(_p), _parent);
4645
}

include/rfl/parsing/FieldVariantParser.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct FieldVariantParser {
5757

5858
template <class P>
5959
static void write(const W& _w, const rfl::Variant<FieldTypes...>& _v,
60-
const P& _parent) noexcept {
60+
const P& _parent) {
6161
static_assert(
6262
internal::no_duplicate_field_names<rfl::Tuple<FieldTypes...>>(),
6363
"Externally tagged variants cannot have duplicate field "

include/rfl/parsing/MapParser.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct MapParser {
4444
}
4545

4646
template <class P>
47-
static void write(const W& _w, const MapType& _m, const P& _parent) noexcept {
47+
static void write(const W& _w, const MapType& _m, const P& _parent) {
4848
if constexpr (schemaful::IsSchemafulWriter<W>) {
4949
write_map(_w, _m, _parent);
5050
} else {
@@ -82,8 +82,7 @@ struct MapParser {
8282
}
8383

8484
template <class P>
85-
static void write_map(const W& _w, const MapType& _m,
86-
const P& _parent) noexcept {
85+
static void write_map(const W& _w, const MapType& _m, const P& _parent) {
8786
auto m = ParentType::add_map(_w, _m.size(), _parent);
8887

8988
using ParentMapType =
@@ -122,8 +121,7 @@ struct MapParser {
122121
}
123122

124123
template <class P>
125-
static void write_object(const W& _w, const MapType& _m,
126-
const P& _parent) noexcept {
124+
static void write_object(const W& _w, const MapType& _m, const P& _parent) {
127125
auto obj = ParentType::add_object(_w, _m.size(), _parent);
128126
for (const auto& [k, v] : _m) {
129127
if constexpr (internal::has_reflection_type_v<KeyType>) {

include/rfl/parsing/NamedTupleParser.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ struct NamedTupleParser {
145145

146146
template <class P>
147147
static void write(const W& _w, const NamedTuple<FieldTypes...>& _tup,
148-
const P& _parent) noexcept {
148+
const P& _parent) {
149149
if constexpr (_no_field_names) {
150150
auto arr = ParentType::add_array(_w, _tup.num_fields(), _parent);
151151
build_object(_w, _tup, &arr, std::make_integer_sequence<int, size_>());
@@ -169,7 +169,7 @@ struct NamedTupleParser {
169169
template <int _i>
170170
static void add_field_to_object(const W& _w,
171171
const NamedTuple<FieldTypes...>& _tup,
172-
OutputObjectOrArrayType* _ptr) noexcept {
172+
OutputObjectOrArrayType* _ptr) {
173173
using FieldType = internal::nth_element_t<_i, FieldTypes...>;
174174
using ValueType = std::remove_cvref_t<typename FieldType::Type>;
175175
const auto value = rfl::get<_i>(_tup);
@@ -222,7 +222,7 @@ struct NamedTupleParser {
222222
template <int... _is>
223223
static void build_object(const W& _w, const NamedTuple<FieldTypes...>& _tup,
224224
OutputObjectOrArrayType* _ptr,
225-
std::integer_sequence<int, _is...>) noexcept {
225+
std::integer_sequence<int, _is...>) {
226226
(add_field_to_object<_is>(_w, _tup, _ptr), ...);
227227
}
228228

include/rfl/parsing/Parser_array.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct Parser<R, W, std::array<T, _size>, ProcessorsType> {
5555

5656
template <class P>
5757
static void write(const W& _w, const std::array<T, _size>& _arr,
58-
const P& _parent) noexcept {
58+
const P& _parent) {
5959
auto arr = ParentType::add_array(_w, _size, _parent);
6060
const auto new_parent = typename ParentType::Array{&arr};
6161
for (const auto& e : _arr) {

include/rfl/parsing/Parser_box.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,21 @@ namespace rfl {
1313
namespace parsing {
1414

1515
template <class R, class W, class T, Copyability C, class ProcessorsType>
16-
requires AreReaderAndWriter<R, W, Box<T, C>>
16+
requires AreReaderAndWriter<R, W, Box<T, C>>
1717
struct Parser<R, W, Box<T, C>, ProcessorsType> {
1818
using InputVarType = typename R::InputVarType;
1919

20-
static Result<Box<T, C>> read(const R& _r, const InputVarType& _var) noexcept {
21-
const auto to_box = [](auto&& _t) { return Box<T, C>::make(std::move(_t)); };
20+
static Result<Box<T, C>> read(const R& _r,
21+
const InputVarType& _var) noexcept {
22+
const auto to_box = [](auto&& _t) {
23+
return Box<T, C>::make(std::move(_t));
24+
};
2225
return Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::read(_r, _var)
2326
.transform(to_box);
2427
}
2528

2629
template <class P>
27-
static void write(const W& _w, const Box<T, C>& _box,
28-
const P& _parent) noexcept {
30+
static void write(const W& _w, const Box<T, C>& _box, const P& _parent) {
2931
Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::write(_w, *_box,
3032
_parent);
3133
}

include/rfl/parsing/Parser_bytestring.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ struct Parser<R, W, Bytestring, ProcessorsType> {
2323
}
2424

2525
template <class P>
26-
static void write(const W& _w, const Bytestring& _b,
27-
const P& _parent) noexcept {
26+
static void write(const W& _w, const Bytestring& _b, const P& _parent) {
2827
ParentType::add_value(_w, _b, _parent);
2928
}
3029

0 commit comments

Comments
 (0)