1212#ifndef BOOST_JSON_DETAIL_VALUE_TO_HPP
1313#define BOOST_JSON_DETAIL_VALUE_TO_HPP
1414
15+
16+ #ifndef BOOST_JSON_DETAIL_VALUE_TO_HPP
17+ #define BOOST_JSON_DETAIL_VALUE_TO_HPP
18+ #endif
19+
20+ #ifndef BOOST_JSON_INTRUSIVE_INDEX_INC
21+ #define BOOST_JSON_INTRUSIVE_INDEX_INC ((void )0 );
22+ #endif
23+
24+ #ifndef BOOST_JSON_INTRUSIVE_PATH_PUSH
25+ #define BOOST_JSON_INTRUSIVE_PATH_PUSH (x ) ((void )0 );
26+ #endif
27+
28+ #ifndef BOOST_JSON_INTRUSIVE_PATH_POP
29+ #define BOOST_JSON_INTRUSIVE_PATH_POP ((void )0 );
30+ #endif
31+
32+ #ifndef BOOST_JSON_INTRUSIVE_MESSAGE
33+ #define BOOST_JSON_INTRUSIVE_MESSAGE (x ) ((void )0 );
34+ #endif
35+
36+
1537#include < boost/json/value.hpp>
1638#include < boost/json/conversion.hpp>
1739#include < boost/json/result_for.hpp>
@@ -270,13 +292,21 @@ value_to_impl(
270292 }
271293
272294 auto ins = detail::inserter (result, inserter_implementation<T>());
295+
296+ BOOST_JSON_INTRUSIVE_PATH_PUSH (-1 )
297+
273298 for ( value const & val: *arr )
274299 {
300+ BOOST_JSON_INTRUSIVE_INDEX_INC
301+
275302 auto elem_res = try_value_to<value_type<T>>( val, ctx );
276303 if ( elem_res.has_error () )
277304 return {boost::system::in_place_error, elem_res.error ()};
278305 *ins++ = std::move (*elem_res);
279306 }
307+
308+ BOOST_JSON_INTRUSIVE_PATH_POP
309+
280310 return result;
281311}
282312
@@ -339,6 +369,16 @@ value_to_impl(
339369 if ( N != arr->size () )
340370 {
341371 BOOST_JSON_FAIL (ec, error::size_mismatch);
372+
373+ using Ds = described_members<T>;
374+ using D = boost::mp11::mp_first<Ds>;
375+
376+ BOOST_JSON_INTRUSIVE_MESSAGE (
377+ std::format (
378+ " while processing array {} in {}, found {} element expected {}" ,
379+ D::name, BOOST_JSON_INTRUSIVE::composePath (),
380+ arr->size (), N));
381+
342382 return {boost::system::in_place_error, ec};
343383 }
344384
@@ -373,10 +413,14 @@ struct to_described_member
373413 system::error_code ec;
374414 BOOST_JSON_FAIL (ec, error::size_mismatch);
375415 res = {boost::system::in_place_error, ec};
416+
417+ BOOST_JSON_INTRUSIVE_MESSAGE (std::format (" the key >> {} << is non optional and missing in path {}" , D::name, BOOST_JSON_INTRUSIVE::composePath ()));
376418 }
377419 return ;
378420 }
379421
422+ BOOST_JSON_INTRUSIVE_PATH_PUSH (D::name)
423+
380424#if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000
381425# pragma GCC diagnostic push
382426# pragma GCC diagnostic ignored "-Wunused"
@@ -386,8 +430,10 @@ struct to_described_member
386430#if defined(__GNUC__) && BOOST_GCC_VERSION >= 80000 && BOOST_GCC_VERSION < 11000
387431# pragma GCC diagnostic pop
388432#endif
389- if ( member_res )
433+ if ( member_res ){
390434 (*res).* D::pointer = std::move (*member_res);
435+ BOOST_JSON_INTRUSIVE_PATH_POP
436+ }
391437 else
392438 res = {boost::system::in_place_error, member_res.error ()};
393439 }
0 commit comments