File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#include < ostream>
77
88#include " ../Processors.hpp"
9+ #include " ../Result.hpp"
910#include " ../parsing/Parent.hpp"
1011#include " Parser.hpp"
1112
@@ -21,10 +22,16 @@ std::vector<char> write(const auto& _obj) {
2122 msgpack_packer pk;
2223 msgpack_packer_init (&pk, &sbuf, msgpack_sbuffer_write);
2324 auto w = Writer (&pk);
24- Parser<T, Processors<Ps...>>::write (w, _obj, typename ParentType::Root{});
25- auto bytes = std::vector<char >(sbuf.data , sbuf.data + sbuf.size );
25+ const auto bytes = [&]() -> Result<std::vector<char >> {
26+ try {
27+ Parser<T, Processors<Ps...>>::write (w, _obj, typename ParentType::Root{});
28+ return std::vector<char >(sbuf.data , sbuf.data + sbuf.size );
29+ } catch (const std::exception& e) {
30+ return error (e.what ());
31+ }
32+ }();
2633 msgpack_sbuffer_destroy (&sbuf);
27- return bytes;
34+ return bytes. value () ;
2835}
2936
3037// / Writes a MSGPACK into an ostream.
You can’t perform that action at this time.
0 commit comments