@@ -41,7 +41,9 @@ namespace error {
4141// / These are platform-specific error codes, for which we have seen variance.
4242// / boost::system::errc::errc_t is the boost::system error condition enum.
4343// / By comparing against conditions we obtain platform-independent error codes.
44+ typedef boost::json::error json_error_t ;
4445typedef boost::beast::http::error http_error_t ;
46+ typedef boost::beast::websocket::error ws_error_t ;
4547typedef boost::system::errc::errc_t boost_error_t ;
4648typedef boost::asio::error::misc_errors asio_misc_error_t ;
4749typedef boost::asio::error::netdb_errors asio_netdb_error_t ;
@@ -229,6 +231,47 @@ enum error_t : uint8_t
229231 bad_close_size,
230232 bad_close_payload,
231233
234+ // boost json error
235+ syntax,
236+ extra_data,
237+ incomplete,
238+ exponent_overflow,
239+ too_deep,
240+ illegal_leading_surrogate,
241+ illegal_trailing_surrogate,
242+ expected_hex_digit,
243+ expected_utf16_escape,
244+ object_too_large,
245+ array_too_large,
246+ key_too_large,
247+ string_too_large,
248+ number_too_large,
249+ input_error,
250+ exception,
251+ out_of_range,
252+ test_failure,
253+ missing_slash,
254+ invalid_escape,
255+ token_not_number,
256+ value_is_scalar,
257+ json_not_found,
258+ token_overflow,
259+ past_the_end,
260+ not_number,
261+ not_exact,
262+ not_null,
263+ not_bool,
264+ not_array,
265+ not_object,
266+ not_string,
267+ not_int64,
268+ not_uint64,
269+ not_double,
270+ not_integer,
271+ size_mismatch,
272+ exhausted_variants,
273+ unknown_name,
274+
232275 // rpc error
233276 message_overflow,
234277 undefined_type,
@@ -244,21 +287,25 @@ enum error_t : uint8_t
244287// No current need for error_code equivalence mapping.
245288DECLARE_ERROR_T_CODE_CATEGORY (error);
246289
247- // / Construct a boost_code object from a boost system errc_t.
248- // / Unfortunately boost_code does not have this std::error_code construction.
249- inline boost_code to_boost_code (boost_error_t ec) NOEXCEPT
290+ inline boost_code to_system_code (boost_error_t ec) NOEXCEPT
250291{
251- return boost_code{ ec, boost::system::generic_category () } ;
292+ return boost::system::errc::make_error_code (ec) ;
252293}
253294
254- // / Unfortunately boost_code does not have this std::error_code construction.
255295inline boost_code to_http_code (http_error_t ec) NOEXCEPT
256296{
257297 return boost::beast::http::make_error_code (ec);
258298}
259299
260- // / Shortcircuit common boost code mapping.
261- BCT_API bool asio_is_canceled (const boost_code& ec) NOEXCEPT;
300+ inline boost_code to_ws_code (ws_error_t ec) NOEXCEPT
301+ {
302+ return boost::beast::websocket::make_error_code (ec);
303+ }
304+
305+ inline boost_code to_json_code (json_error_t ec) NOEXCEPT
306+ {
307+ return boost::json::make_error_code (ec);
308+ }
262309
263310// / Unfortunately std::error_code and boost::system::error_code are distinct
264311// / types, so they do not compare as would be expected across distinct
@@ -269,14 +316,22 @@ BCT_API bool asio_is_canceled(const boost_code& ec) NOEXCEPT;
269316// / codes to network::error_t codes. This cannot be done using the equivalence
270317// / operator overloads of either, since the error_code types are distinct,
271318// / despite being effectively identical. So we provide this explicit mapping.
319+
320+ // / Shortcircuit common boost code mapping.
321+ BCT_API bool asio_is_canceled (const boost_code& ec) NOEXCEPT;
322+
323+ // / mapping of boost::asio error codes to network (or error::unknown).
272324BCT_API code asio_to_error_code (const boost_code& ec) NOEXCEPT;
273325
274326// / 1:1 mapping of boost::beast:http::error to network (or error::unknown).
275327BCT_API code http_to_error_code (const boost_code& ec) NOEXCEPT;
276328
277- // / 1:1 mapping of boost::beast:websocket::error to network (or error::unknown).
329+ // / 1:1 mapping of boost::beast:: websocket::error to network (or error::unknown).
278330BCT_API code ws_to_error_code (const boost_code& ec) NOEXCEPT;
279331
332+ // / 1:1 mapping of boost::json::error to network (or error::unknown).
333+ BCT_API code json_to_error_code (const boost_code& ec) NOEXCEPT;
334+
280335} // namespace error
281336} // namespace network
282337} // namespace libbitcoin
0 commit comments