|
2 | 2 | #define RFL_PARSING_PARSER_TAGGED_UNION_HPP_
|
3 | 3 |
|
4 | 4 | #include <map>
|
| 5 | +#include <sstream> |
5 | 6 | #include <type_traits>
|
6 | 7 |
|
7 | 8 | #include "../Result.hpp"
|
@@ -91,10 +92,12 @@ struct Parser<R, W, TaggedUnion<_discriminator, AlternativeTypes...>,
|
91 | 92 | return res;
|
92 | 93 | } else {
|
93 | 94 | const auto names = PossibleTags::names();
|
94 |
| - return Error("Could not parse tagged union, could not match " + |
95 |
| - _discriminator.str() + " '" + _disc_value + |
96 |
| - "'. The following tags are allowed: " + |
97 |
| - internal::strings::join(", ", names)); |
| 95 | + std::stringstream stream; |
| 96 | + stream << "Could not parse tagged union, could not match " |
| 97 | + << _discriminator.str() << " '" << _disc_value |
| 98 | + << "'. The following tags are allowed: " |
| 99 | + << internal::strings::join(", ", names); |
| 100 | + return Error(stream.str()); |
98 | 101 | }
|
99 | 102 | }
|
100 | 103 |
|
@@ -122,10 +125,12 @@ struct Parser<R, W, TaggedUnion<_discriminator, AlternativeTypes...>,
|
122 | 125 | };
|
123 | 126 |
|
124 | 127 | const auto embellish_error = [&](Error&& _e) {
|
125 |
| - return Error( |
126 |
| - "Could not parse tagged union with " |
127 |
| - "discrimininator " + |
128 |
| - _discriminator.str() + " '" + _disc_value + "': " + _e.what()); |
| 128 | + std::stringstream stream; |
| 129 | + stream << "Could not parse tagged union with " |
| 130 | + "discrimininator " |
| 131 | + << _discriminator.str() << " '" << _disc_value |
| 132 | + << "': " << _e.what(); |
| 133 | + return Error(stream.str()); |
129 | 134 | };
|
130 | 135 |
|
131 | 136 | if constexpr (no_field_names_) {
|
@@ -153,9 +158,10 @@ struct Parser<R, W, TaggedUnion<_discriminator, AlternativeTypes...>,
|
153 | 158 | };
|
154 | 159 |
|
155 | 160 | const auto embellish_error = [](const auto&) {
|
156 |
| - return Error("Could not parse tagged union: Could not find field '" + |
157 |
| - _discriminator.str() + |
158 |
| - "' or type of field was not a string."); |
| 161 | + std::stringstream stream; |
| 162 | + stream << "Could not parse tagged union: Could not find field '" |
| 163 | + << _discriminator.str() << "' or type of field was not a string."; |
| 164 | + return Error(stream.str()); |
159 | 165 | };
|
160 | 166 |
|
161 | 167 | if constexpr (no_field_names_) {
|
|
0 commit comments