|
8 | 8 |
|
9 | 9 | #include "MantidGeometry/Crystal/MatrixVectorPair.h"
|
10 | 10 | #include "MantidGeometry/Crystal/V3R.h"
|
| 11 | +#include "MantidKernel/Exception.h" |
11 | 12 |
|
12 | 13 | #include <boost/parser/parser.hpp>
|
13 | 14 |
|
@@ -175,9 +176,9 @@ template <typename T> MatrixVectorPair<T, V3R> parseMatrixVectorPair(const std::
|
175 | 176 |
|
176 | 177 | auto negativeSignAction = [&builder](auto const &) { builder.setCurrentSignNegative(); };
|
177 | 178 |
|
178 |
| - auto currentFactorAction = [&builder](auto &ctx) { builder.setCurrentFactor(_attr(ctx)); }; |
| 179 | + auto currentFactorAction = [&builder](auto const &ctx) { builder.setCurrentFactor(_attr(ctx)); }; |
179 | 180 |
|
180 |
| - auto currentDirectionAction = [&builder](auto &ctx) { builder.setCurrentDirection(_attr(ctx)); }; |
| 181 | + auto currentDirectionAction = [&builder](auto const &ctx) { builder.setCurrentDirection(_attr(ctx)); }; |
181 | 182 |
|
182 | 183 | auto addCurrentStateToResultAction = [&builder](auto const &) { builder.addCurrentStateToResult(); };
|
183 | 184 |
|
@@ -208,22 +209,16 @@ template <typename T> MatrixVectorPair<T, V3R> parseMatrixVectorPair(const std::
|
208 | 209 | auto m_parser = (m_componentSeries >> lit(',')[advanceRowAction] >> m_componentSeries >> lit(',')[advanceRowAction] >>
|
209 | 210 | m_componentSeries);
|
210 | 211 |
|
211 |
| - auto success = parse(matrixVectorString, m_parser); |
| 212 | + try { |
| 213 | + auto success = parse(matrixVectorString, m_parser, bp::ws); |
212 | 214 |
|
213 |
| - if (!success) { |
214 |
| - throw std::runtime_error("Parse error"); |
| 215 | + if (!success) { |
| 216 | + throw std::runtime_error("Parse error in '" + matrixVectorString + "'."); |
| 217 | + } |
| 218 | + } catch (std::runtime_error &builderError) { |
| 219 | + throw Kernel::Exception::ParseError("Parse error: " + std::string(builderError.what()), matrixVectorString, 0); |
215 | 220 | }
|
216 | 221 |
|
217 |
| - // try { |
218 |
| - // qi::phrase_parse(strIterator, strEnd, parser, qi::space); |
219 |
| - |
220 |
| - // if (std::distance(strIterator, strEnd) > 0) { |
221 |
| - // throw std::runtime_error("Additional characters at end of string: '" + std::string(strIterator, strEnd) + "'."); |
222 |
| - // } |
223 |
| - //} catch (std::runtime_error &builderError) { |
224 |
| - // throw Kernel::Exception::ParseError("Parse error: " + std::string(builderError.what()), matrixVectorString, 0); |
225 |
| - //} |
226 |
| - |
227 | 222 | return builder.getMatrixVectorPair<T>();
|
228 | 223 | }
|
229 | 224 |
|
|
0 commit comments