• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libbitcoin / libbitcoin-network / 41461354711

02 Nov 2026 02:22PM UTC coverage: 94.148% (-0.6%) from 94.709%
41461354711

push

github

web-flow
Merge pull request #1000 from evoskuil/master

Remove boost dependency.

3160 of 3544 new or added lines in 90 files covered. (89.16%)

10 existing lines in 6 files now uncovered.

13322 of 14150 relevant lines covered (94.15%)

2655.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.34
/src/error.cpp
1
/**
2
 * Copyright (c) 2011-2026 libbitcoin developers
3
 *
4
 * This file is part of libbitcoin.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
#include <bitcoin/network/error.hpp>
20

21
#include <bitcoin/network/define.hpp>
22
#include <bitcoin/network/tls/constants.hpp>
23

24
namespace libbitcoin {
25
namespace network {
26
namespace error {
27

28
BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
29

30
DEFINE_ERROR_T_MESSAGE_MAP(error)
31
{
32
    { success, "success" },
33
    { unknown, "unknown error" },
34
    { upgrade, "upgrade requested" },
35
    { upgraded, "upgraded" },
36

37
    // addresses
38
    { address_invalid, "address invalid" },
39
    { address_not_found, "address not found" },
40
    { address_disabled, "address protocol disabled" },
41
    { address_unsupported, "advertised services unsupported" },
42
    { address_insufficient, "advertised services insufficient" },
43
    { seeding_unsuccessful, "seeding unsuccessful" },
44
    { seeding_complete, "seeding complete" },
45
        
46
    // file system
47
    { file_load, "failed to load file" },
48
    { file_save, "failed to save file" },
49
    { file_system, "file system error" },
50
    { file_exception, "file exception" },
51

52
    // general I/O failures
53
    { bad_stream, "bad data stream" },
54
    { not_allowed, "not allowed" },
55
    { peer_disconnect, "peer disconnect" },
56
    { peer_unsupported, "peer unsupported" },
57
    { peer_insufficient, "peer insufficient" },
58
    { peer_timestamp, "peer timestamp" },
59
    { protocol_violation, "protocol violation" },
60
    { channel_overflow, "channel overflow" },
61
    { channel_underflow, "channel underflow" },
62
    { channel_backlog, "channel write backlog" },
63
    { message_dropped, "message dropped" },
64

65
    // incoming connection failures
66
    { listen_failed, "incoming connection failed" },
67
    { accept_failed, "connection to self aborted" },
68
    { oversubscribed, "service oversubscribed" },
69

70
    // incoming/outgoing connection failures
71
    { address_blocked, "address blocked by policy" },
72
        
73
    // outgoing connection failures
74
    { address_in_use, "address already in use" },
75
    { resolve_failed, "resolving hostname failed" },
76
    { connect_failed, "unable to reach remote host" },
77
    { net_unreachable, "network unreachable" },
78
    { host_unreachable, "host unreachable" },
79
    { connection_refused, "connection refused" },
80

81
    // heading read failures
82
    { invalid_heading, "invalid message heading" },
83
    { invalid_magic, "invalid message heading magic" },
84

85
    // payload read failures
86
    { oversized_payload, "oversize message payload" },
87
    { invalid_checksum, "invalid message checksum" },
88
    { invalid_message, "message failed to deserialize" },
89
    { unknown_message, "unknown message type" },
90

91
    // general failures
92
    { invalid_configuration, "invalid configuration" },
93
    { insufficient_buffer, "insufficient buffer space" },
94
    { operation_timeout, "operation timed out" },
95
    { operation_canceled, "operation canceled" },
96
    { operation_failed, "operation failed" },
97

98
    // termination
99
    { channel_timeout, "channel timed out" },
100
    { channel_conflict, "channel conflict" },
101
    { channel_dropped, "channel dropped" },
102
    { channel_expired, "channel expired" },
103
    { channel_inactive, "channel inactive" },
104
    { channel_stopped, "channel stopped" },
105
    { service_stopped, "service stopped" },
106
    { service_suspended, "service suspended" },
107
    { subscriber_exists, "subscriber exists" },
108
    { subscriber_stopped, "subscriber stopped" },
109
    { desubscribed, "subscriber desubscribed" },
110

111
    // socks5
112
    { socks_method, "socks method not supported" },
113
    { socks_username, "socks username too long" },
114
    { socks_password, "socks password too long" },
115
    { socks_host_name, "socks host name too long" },
116
    { socks_authentication, "socks authentication failed" },
117
    { socks_failure, "socks failure" },
118
    { socks_disallowed, "socks connection disallowed" },
119
    { socks_net_unreachable, "socks network unreachable" },
120
    { socks_host_unreachable, "socks host unreachable" },
121
    { socks_connection_refused, "socks connection refused" },
122
    { socks_connection_expired, "socks connection expired" },
123
    { socks_unsupported_command, "socks unsupported command" },
124
    { socks_unsupported_address, "socks unsupported address" },
125
    { socks_unassigned_failure, "socks unassigned failure" },
126
    { socks_response_invalid, "socks response invalid" },
127

128
    // sam
129
    { sam_response_invalid, "sam response invalid" },
130
    { sam_no_version, "sam version not supported" },
131
    { sam_cant_reach_peer, "sam cannot reach peer" },
132
    { sam_duplicated_dest, "sam duplicated destination" },
133
    { sam_duplicated_id, "sam duplicated session" },
134
    { sam_i2p_error, "sam i2p error" },
135
    { sam_invalid_id, "sam invalid session" },
136
    { sam_invalid_key, "sam invalid key" },
137
    { sam_key_not_found, "sam key not found" },
138
    { sam_peer_not_found, "sam peer not found" },
139
    { sam_timeout, "sam timeout" },
140
    { sam_unassigned_failure, "sam unassigned failure" },
141

142
    // tls
143
    { tls_use_certificate, "failed to set tls certificate" },
144
    { tls_use_private_key, "failed to set tls private key" },
145
    { tls_set_add_verify, "failed to set tls certificate authority" },
146
    { tls_stream_truncated, "tls stream truncated" },
147

148
    // tls alerts
149
    { tls_alert_unexpected_message, "tls alert unexpected message" },
150
    { tls_alert_bad_record_mac, "tls alert bad record mac" },
151
    { tls_alert_record_overflow, "tls alert record overflow" },
152
    { tls_alert_handshake_failure, "tls alert handshake failure" },
153
    { tls_alert_bad_certificate, "tls alert bad certificate" },
154
    { tls_alert_unsupported_certificate, "tls alert unsupported certificate" },
155
    { tls_alert_certificate_expired, "tls alert certificate expired" },
156
    { tls_alert_certificate_unknown, "tls alert certificate unknown" },
157
    { tls_alert_illegal_parameter, "tls alert illegal parameter" },
158
    { tls_alert_unknown_ca, "tls alert unknown ca" },
159
    { tls_alert_decode_error, "tls alert decode error" },
160
    { tls_alert_decrypt_error, "tls alert decrypt error" },
161
    { tls_alert_protocol_version, "tls alert protocol version" },
162
    { tls_alert_internal_error, "tls alert internal error" },
163
    { tls_alert_missing_extension, "tls alert missing extension" },
164
    { tls_alert_certificate_required, "tls alert certificate required" },
165
    { tls_alert_unknown, "tls alert" },
166

167
    // http 4xx client error
168
    { bad_request, "bad request" },
169
    { unauthorized, "unauthorized" },
170
    ////{ payment_required, "payment required" },
171
    { forbidden, "forbidden" },
172
    { not_found, "not found" },
173
    { method_not_allowed, "method not allowed" },
174
    { not_acceptable, "not acceptable" },
175
    ////{ proxy_authentication_required, "proxy authentication required" },
176
    ////{ request_timeout, "request timeout" },
177
    ////{ conflict, "conflict" },
178
    ////{ gone, "gone" },
179
    ////{ length_required, "length required" },
180
    ////{ precondition_failed, "precondition failed" },
181
    ////{ payload_too_large, "payload too large" },
182
    ////{ uri_too_long, "uri too long" },
183
    ////{ unsupported_media_type, "unsupported media type" },
184
    ////{ range_not_satisfiable, "range not satisfiable" },
185
    ////{ expectation_failed, "expectation failed" },
186
    ////{ im_a_teapot, "im a teapot" },
187
    ////{ misdirected_request, "misdirected request" },
188
    ////{ unprocessable_entity, "unprocessable entity" },
189
    ////{ locked, "locked" },
190
    ////{ failed_dependency, "failed dependency" },
191
    ////{ too_early, "too early" },
192
    ////{ upgrade_required, "upgrade required" },
193
    ////{ precondition_required, "precondition required" },
194
    ////{ too_many_requests, "too many requests" },
195
    ////{ request_header_fields_too_large, "request header fields too large" },
196
    ////{ unavailable_for_legal_reasons, "unavailable for legal reasons" },
197

198
    // http 5xx server error
199
    { internal_server_error, "internal server error" },
200
    { not_implemented, "not implemented" },
201
    ////{ bad_gateway, "bad gateway" },
202
    ////{ service_unavailable, "service unavailable" },
203
    ////{ gateway_timeout, "gateway timeout" },
204
    ////{ http_version_not_supported, "http version not supported" },
205
    ////{ variant_also_negotiates, "variant also negotiates" },
206
    ////{ insufficient_storage, "insufficient storage" },
207
    ////{ loop_detected, "loop detected" },
208
    ////{ not_extended, "not extended" },
209
    ////{ network_authentication_required, "network authentication required" },
210

211
    // http error
212
    { end_of_stream, "end of stream" },
213
    { partial_message, "partial message" },
214
    { need_more, "need more" },
215
    { unexpected_body, "unexpected body" },
216
    { need_buffer, "need buffer" },
217
    { end_of_chunk, "end of chunk" },
218
    { buffer_overflow, "buffer overflow" },
219
    { header_limit, "header limit" },
220
    { body_limit, "body limit" },
221
    { bad_alloc, "bad alloc" },
222
    { bad_line_ending, "bad line ending" },
223
    { bad_method, "bad method" },
224
    { bad_target, "bad target" },
225
    { bad_version, "bad version" },
226
    { bad_status, "bad status" },
227
    { bad_reason, "bad reason" },
228
    { bad_field, "bad field" },
229
    { bad_value, "bad value" },
230
    { bad_content_length, "bad content length" },
231
    { bad_transfer_encoding, "bad transfer encoding" },
232
    { bad_chunk, "bad chunk" },
233
    { bad_chunk_extension, "bad chunk extension" },
234
    { bad_obs_fold, "bad obs fold" },
235
    { multiple_content_length, "multiple content length" },
236
    { stale_parser, "stale parser" },
237
    { short_read, "short read" },
238
    { http_unknown, "http error" },
239

240
    // websocket error
241
    { websocket_closed, "websocket closed" },
242
    { websocket_buffer_overflow, "websocket buffer overflow" },
243
    { partial_deflate_block, "partial deflate block" },
244
    { message_too_big, "message too big" },
245
    { bad_http_version, "bad http version" },
246
    { websocket_bad_method, "websocket bad method" },
247
    { no_host, "no host" },
248
    { no_connection, "no connection" },
249
    { no_connection_upgrade, "no connection upgrade" },
250
    { no_upgrade, "no upgrade" },
251
    { no_upgrade_websocket, "no upgrade websocket" },
252
    { no_sec_key, "no sec key" },
253
    { bad_sec_key, "bad sec key" },
254
    { no_sec_version, "no sec version" },
255
    { bad_sec_version, "bad sec version" },
256
    { no_sec_accept, "no sec accept" },
257
    { bad_sec_accept, "bad sec accept" },
258
    { upgrade_declined, "upgrade declined" },
259
    { bad_opcode, "bad opcode" },
260
    { bad_data_frame, "bad data frame" },
261
    { bad_continuation, "bad continuation" },
262
    { bad_reserved_bits, "bad reserved bits" },
263
    { bad_control_fragment, "bad control fragment" },
264
    { bad_control_size, "bad control size" },
265
    { bad_unmasked_frame, "bad unmasked frame" },
266
    { bad_masked_frame, "bad masked frame" },
267
    { bad_size, "bad size" },
268
    { bad_frame_payload, "bad frame payload" },
269
    { bad_close_code, "bad close code" },
270
    { bad_close_size, "bad close size" },
271
    { bad_close_payload, "bad close payload" },
272

273
    // json error
274
    { syntax, "syntax error" },
275
    { extra_data, "extra data" },
276
    { incomplete, "incomplete json" },
277
    { too_deep, "too deep" },
278
    { invalid_escape, "invalid escape" },
279
    { expected_hex_digit, "expected hex digit" },
280
    { expected_utf16_escape, "expected utf16 escape" },
281
    { illegal_leading_surrogate, "illegal leading surrogate" },
282
    { illegal_trailing_surrogate, "illegal trailing surrogate" },
283
    { invalid_utf8, "invalid utf8" },
284
    { exponent_overflow, "exponent too large" },
285
    { number_too_large, "number too large" },
286
    { string_too_large, "string too large" },
287
    { key_too_large, "key too large" },
288
    { array_too_large, "array too large" },
289
    { object_too_large, "object too large" },
290
    { not_null, "not null" },
291
    { not_bool, "not bool" },
292
    { not_number, "not number" },
293
    { not_int64, "not int64" },
294
    { not_uint64, "not uint64" },
295
    { not_double, "not double" },
296
    { not_string, "not string" },
297
    { not_array, "not array" },
298
    { not_object, "not object" },
299
    { not_exact, "not exact" },
300
    { out_of_range, "out of range" },
301
    { size_mismatch, "size mismatch" },
302
    { exhausted_variants, "exhausted variants" },
303
    { json_unknown, "json error" },
304

305
    // query string parse error
306
    { undefined_type, "undefined type" },
307
    { unexpected_method, "unexpected method" },
308
    { unexpected_type, "unexpected type" },
309
    { extra_positional, "extra positional" },
310
    { extra_named, "extra named" },
311
    { missing_array, "missing array" },
312
    { missing_object, "missing object" },
313
    { missing_parameter, "missing parameter" },
314

315
    // json-rpc error
316
    { jsonrpc_invalid_version, "jsonrpc invalid version" },
317
    { jsonrpc_requires_method, "jsonrpc requires method" },
318
    { jsonrpc_v1_requires_params, "jsonrpc v1 requires params" },
319
    { jsonrpc_v1_requires_array_params, "jsonrpc v1 requires array params" },
320
    { jsonrpc_v1_requires_id, "jsonrpc v1 requires id" },
321
    { jsonrpc_params_not_collection, "jsonrpc params not collection" },
322
    { jsonrpc_reader_stall, "jsonrpc reader stall" },
323
    { jsonrpc_reader_exception, "jsonrpc reader exception" },
324
    { jsonrpc_writer_exception, "jsonrpc writer exception" },
325
    { jsonrpc_batch_empty, "jsonrpc batch empty" },
326
    { jsonrpc_batch_malformed, "jsonrpc batch malformed" },
327
    { jsonrpc_batch_requires_v2, "jsonrpc batch requires v2" },
328
    { jsonrpc_batch_unsupported, "jsonrpc batch unsupported" },
329

330
    // zmtp (rpc by socket role)
331
    { zmtp_unexpected_command, "zmtp unexpected command" },
332
    { zmtp_unexpected_message, "zmtp unexpected message" },
333
    { zmtp_excessive_parts, "zmtp excessive parts" },
334
    { zmtp_unserializable, "zmtp unserializable" },
335

336
    // io
337
    { would_block, "would block" }
338
};
339

340
DEFINE_ERROR_T_CATEGORY(error, "network", "network code")
288,801 ✔
341

342
class http_category_t final
343
  : public std::error_category
344
{
345
public:
NEW
346
    const char* name() const noexcept override
×
347
    {
NEW
348
        return "libbitcoin.http";
×
349
    }
350

NEW
351
    std::string message(int value) const override
×
352
    {
NEW
353
        switch (static_cast<http_error_t>(value))
×
354
        {
NEW
355
            case http_error_t::end_of_stream: return "end of stream";
×
NEW
356
            case http_error_t::partial_message: return "partial message";
×
NEW
357
            case http_error_t::need_more: return "need more";
×
NEW
358
            case http_error_t::unexpected_body: return "unexpected body";
×
NEW
359
            case http_error_t::need_buffer: return "need buffer";
×
NEW
360
            case http_error_t::end_of_chunk: return "end of chunk";
×
NEW
361
            case http_error_t::buffer_overflow: return "buffer overflow";
×
NEW
362
            case http_error_t::header_limit: return "header limit exceeded";
×
NEW
363
            case http_error_t::body_limit: return "body limit exceeded";
×
NEW
364
            case http_error_t::bad_alloc: return "bad alloc";
×
NEW
365
            case http_error_t::bad_line_ending: return "bad line ending";
×
NEW
366
            case http_error_t::bad_method: return "bad method";
×
NEW
367
            case http_error_t::bad_target: return "bad target";
×
NEW
368
            case http_error_t::bad_version: return "bad version";
×
NEW
369
            case http_error_t::bad_status: return "bad status";
×
NEW
370
            case http_error_t::bad_reason: return "bad reason";
×
NEW
371
            case http_error_t::bad_field: return "bad field";
×
NEW
372
            case http_error_t::bad_value: return "bad value";
×
NEW
373
            case http_error_t::bad_content_length: return "bad Content-Length";
×
NEW
374
            case http_error_t::bad_transfer_encoding: return "bad Transfer-Encoding";
×
NEW
375
            case http_error_t::bad_chunk: return "bad chunk";
×
NEW
376
            case http_error_t::bad_chunk_extension: return "bad chunk extension";
×
NEW
377
            case http_error_t::bad_obs_fold: return "bad obs-fold";
×
NEW
378
            case http_error_t::multiple_content_length: return "multiple Content-Length";
×
NEW
379
            case http_error_t::stale_parser: return "stale parser";
×
NEW
380
            case http_error_t::short_read: return "unexpected eof in body";
×
NEW
381
            default: return "http error";
×
382
        }
383
    }
384
};
385

386
const std::error_category& http_category() NOEXCEPT
1,602 ✔
387
{
388
    static const http_category_t instance{};
1,602 ✔
389
    return instance;
1,602 ✔
390
}
391

392
// includes json codes
393
code http_to_error_code(const code& ec) NOEXCEPT
340 ✔
394
{
395
    if (!ec)
340 ✔
396
        return error::success;
282 ✔
397

398
    if (ec.category() == to_http_code(http_error_t::end_of_stream).category())
58 ✔
399
    {
400
        switch (static_cast<http_error_t>(ec.value()))
55 ✔
401
        {
402
            case http_error_t::end_of_stream: return error::end_of_stream;
2 ✔
403
            case http_error_t::partial_message: return error::partial_message;
2 ✔
404
            case http_error_t::need_more: return error::need_more;
1 ✔
405
            case http_error_t::unexpected_body: return error::unexpected_body;
1 ✔
406
            case http_error_t::need_buffer: return error::need_buffer;
16 ✔
407
            case http_error_t::end_of_chunk: return error::end_of_chunk;
1 ✔
408
            case http_error_t::buffer_overflow: return error::buffer_overflow;
1 ✔
409
            case http_error_t::header_limit: return error::header_limit;
3 ✔
410
            case http_error_t::body_limit: return error::body_limit;
2 ✔
411
            case http_error_t::bad_alloc: return error::bad_alloc;
1 ✔
412
            case http_error_t::bad_line_ending: return error::bad_line_ending;
1 ✔
413
            case http_error_t::bad_method: return error::bad_method;
2 ✔
414
            case http_error_t::bad_target: return error::bad_target;
1 ✔
415
            case http_error_t::bad_version: return error::bad_version;
1 ✔
416
            case http_error_t::bad_status: return error::bad_status;
1 ✔
417
            case http_error_t::bad_reason: return error::bad_reason;
1 ✔
418
            case http_error_t::bad_field: return error::bad_field;
1 ✔
419
            case http_error_t::bad_value: return error::bad_value;
7 ✔
420
            case http_error_t::bad_content_length: return error::bad_content_length;
1 ✔
421
            case http_error_t::bad_transfer_encoding: return error::bad_transfer_encoding;
1 ✔
422
            case http_error_t::bad_chunk: return error::bad_chunk;
1 ✔
423
            case http_error_t::bad_chunk_extension: return error::bad_chunk_extension;
1 ✔
424
            case http_error_t::bad_obs_fold: return error::bad_obs_fold;
1 ✔
425
            case http_error_t::multiple_content_length: return error::multiple_content_length;
2 ✔
426
            case http_error_t::stale_parser: return error::stale_parser;
1 ✔
427
            case http_error_t::short_read: return error::short_read;
1 ✔
428
            default: return error::http_unknown;
1 ✔
429
        }
430
    }
431

432
    return json_to_error_code(ec);
3 ✔
433
}
434

435
code tls_to_error_code(uint8_t alert) NOEXCEPT
20 ✔
436
{
437
    switch (alert)
20 ✔
438
    {
439
        case tls::alert::unexpected_message: return error::tls_alert_unexpected_message;
1 ✔
440
        case tls::alert::bad_record_mac: return error::tls_alert_bad_record_mac;
2 ✔
441
        case tls::alert::record_overflow: return error::tls_alert_record_overflow;
1 ✔
442
        case tls::alert::handshake_failure: return error::tls_alert_handshake_failure;
1 ✔
443
        case tls::alert::bad_certificate: return error::tls_alert_bad_certificate;
1 ✔
444
        case tls::alert::unsupported_certificate: return error::tls_alert_unsupported_certificate;
1 ✔
445
        case tls::alert::certificate_expired: return error::tls_alert_certificate_expired;
1 ✔
446
        case tls::alert::certificate_unknown: return error::tls_alert_certificate_unknown;
1 ✔
447
        case tls::alert::illegal_parameter: return error::tls_alert_illegal_parameter;
1 ✔
448
        case tls::alert::unknown_ca: return error::tls_alert_unknown_ca;
1 ✔
449
        case tls::alert::decode_error: return error::tls_alert_decode_error;
1 ✔
450
        case tls::alert::decrypt_error: return error::tls_alert_decrypt_error;
1 ✔
451
        case tls::alert::protocol_version: return error::tls_alert_protocol_version;
1 ✔
452
        case tls::alert::internal_error: return error::tls_alert_internal_error;
1 ✔
453
        case tls::alert::missing_extension: return error::tls_alert_missing_extension;
1 ✔
454
        case tls::alert::certificate_required: return error::tls_alert_certificate_required;
2 ✔
455
        default: return error::tls_alert_unknown;
2 ✔
456
    }
457
}
458

459
// network codes pass
460
code json_to_error_code(const code& ec) NOEXCEPT
36 ✔
461
{
462
    if (!ec)
36 ✔
463
        return error::success;
1 ✔
464

465
    if (ec.category() == system::error::json_error_category::singleton)
35 ✔
466
    {
467
        switch (static_cast<json_error_t>(ec.value()))
33 ✔
468
        {
469
            case json_error_t::json_syntax: return error::syntax;
3 ✔
470
            case json_error_t::json_extra_data: return error::extra_data;
1 ✔
471
            case json_error_t::json_incomplete: return error::incomplete;
2 ✔
472
            case json_error_t::json_too_deep: return error::too_deep;
1 ✔
473
            case json_error_t::json_invalid_escape: return error::invalid_escape;
1 ✔
474
            case json_error_t::json_expected_hex_digit: return error::expected_hex_digit;
1 ✔
475
            case json_error_t::json_expected_utf16_escape: return error::expected_utf16_escape;
1 ✔
476
            case json_error_t::json_illegal_leading_surrogate: return error::illegal_leading_surrogate;
1 ✔
477
            case json_error_t::json_illegal_trailing_surrogate: return error::illegal_trailing_surrogate;
1 ✔
478
            case json_error_t::json_invalid_utf8: return error::invalid_utf8;
1 ✔
479
            case json_error_t::json_exponent_overflow: return error::exponent_overflow;
1 ✔
480
            case json_error_t::json_number_too_large: return error::number_too_large;
1 ✔
481
            case json_error_t::json_string_too_large: return error::string_too_large;
1 ✔
482
            case json_error_t::json_key_too_large: return error::key_too_large;
1 ✔
483
            case json_error_t::json_array_too_large: return error::array_too_large;
1 ✔
484
            case json_error_t::json_object_too_large: return error::object_too_large;
1 ✔
485
            case json_error_t::json_not_null: return error::not_null;
1 ✔
486
            case json_error_t::json_not_bool: return error::not_bool;
1 ✔
487
            case json_error_t::json_not_number: return error::not_number;
1 ✔
488
            case json_error_t::json_not_int64: return error::not_int64;
1 ✔
489
            case json_error_t::json_not_uint64: return error::not_uint64;
1 ✔
490
            case json_error_t::json_not_double: return error::not_double;
1 ✔
491
            case json_error_t::json_not_string: return error::not_string;
1 ✔
492
            case json_error_t::json_not_array: return error::not_array;
1 ✔
493
            case json_error_t::json_not_object: return error::not_object;
1 ✔
494
            case json_error_t::json_not_exact: return error::not_exact;
1 ✔
495
            case json_error_t::json_out_of_range: return error::out_of_range;
1 ✔
496
            case json_error_t::json_size_mismatch: return error::size_mismatch;
1 ✔
497
            case json_error_t::json_exhausted_variants: return error::exhausted_variants;
1 ✔
498
            default: return error::json_unknown;
1 ✔
499
        }
500
    }
501

502
    if (ec.category() == network::error::error_category::singleton)
2 ✔
503
        return ec;
1 ✔
504

505
    return error::unknown;
1 ✔
506
}
507

508
// includes http codes
509
code rpc_to_error_code(const code& ec) NOEXCEPT
26 ✔
510
{
511
    if (!ec)
26 ✔
512
        return error::success;
1 ✔
513

514
    if (ec.category() == network::error::error_category::singleton)
25 ✔
515
        return ec;
2 ✔
516

517
    return http_to_error_code(ec);
23 ✔
518
}
519

520
BC_POP_WARNING()
521

522
} // namespace error
523
} // namespace network
524
} // namespace libbitcoin
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc