Skip to content

Commit f308457

Browse files
authored
Stop calling abort() in runtime. (#204)
1 parent e43e8ca commit f308457

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

trantor/net/TcpClient.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void TcpClient::newConnection(int sockfd)
153153
SSLHostName_);
154154
#else
155155
LOG_FATAL << "OpenSSL is not found in your system!";
156-
abort();
156+
throw std::runtime_error("OpenSSL is not found in your system!");
157157
#endif
158158
}
159159
else
@@ -253,6 +253,6 @@ void TcpClient::enableSSL(
253253
(void)keyPath;
254254

255255
LOG_FATAL << "OpenSSL is not found in your system!";
256-
abort();
256+
throw std::runtime_error("OpenSSL is not found in your system!");
257257
#endif
258258
}

trantor/net/TcpServer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void TcpServer::newConnection(int sockfd, const InetAddress &peer)
7676
sslCtxPtr_);
7777
#else
7878
LOG_FATAL << "OpenSSL is not found in your system!";
79-
abort();
79+
throw std::runtime_error("OpenSSL is not found in your system!");
8080
#endif
8181
}
8282
else
@@ -220,6 +220,6 @@ void TcpServer::enableSSL(
220220
(void)sslConfCmds;
221221

222222
LOG_FATAL << "OpenSSL is not found in your system!";
223-
abort();
223+
throw std::runtime_error("OpenSSL is not found in your system!");
224224
#endif
225225
}

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ std::shared_ptr<SSLContext> newSSLServerContext(
327327
{
328328
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
329329
LOG_FATAL << "Reading certificate: " << errbuf;
330-
abort();
330+
throw std::runtime_error("SSL_CTX_use_certificate_chain_file error.");
331331
}
332332
r = SSL_CTX_use_PrivateKey_file(ctx->get(),
333333
keyPath.c_str(),
@@ -336,14 +336,14 @@ std::shared_ptr<SSLContext> newSSLServerContext(
336336
{
337337
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
338338
LOG_FATAL << "Reading private key: " << errbuf;
339-
abort();
339+
throw std::runtime_error("SSL_CTX_use_PrivateKey_file error");
340340
}
341341
r = SSL_CTX_check_private_key(ctx->get());
342342
if (!r)
343343
{
344344
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
345345
LOG_FATAL << "Checking private key matches certificate: " << errbuf;
346-
abort();
346+
throw std::runtime_error("SSL_CTX_check_private_key error");
347347
}
348348
return ctx;
349349
}
@@ -364,7 +364,7 @@ std::shared_ptr<SSLContext> newSSLClientContext(
364364
{
365365
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
366366
LOG_FATAL << "Reading certificate: " << errbuf;
367-
abort();
367+
throw std::runtime_error("SSL_CTX_use_certificate_chain_file error.");
368368
}
369369
r = SSL_CTX_use_PrivateKey_file(ctx->get(),
370370
keyPath.c_str(),
@@ -373,14 +373,14 @@ std::shared_ptr<SSLContext> newSSLClientContext(
373373
{
374374
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
375375
LOG_FATAL << "Reading private key: " << errbuf;
376-
abort();
376+
throw std::runtime_error("SSL_CTX_use_PrivateKey_file error.");
377377
}
378378
r = SSL_CTX_check_private_key(ctx->get());
379379
if (!r)
380380
{
381381
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
382382
LOG_FATAL << "Checking private key matches certificate: " << errbuf;
383-
abort();
383+
throw std::runtime_error("SSL_CTX_check_private_key error.");
384384
}
385385
return ctx;
386386
}
@@ -395,7 +395,7 @@ std::shared_ptr<SSLContext> newSSLServerContext(
395395
const std::vector<std::pair<std::string, std::string>> &)
396396
{
397397
LOG_FATAL << "OpenSSL is not found in your system!";
398-
abort();
398+
throw std::runtime_error("OpenSSL is not found in your system!");
399399
}
400400
} // namespace trantor
401401
#endif
@@ -513,7 +513,7 @@ void TcpConnectionImpl::startServerEncryption(
513513
(void)callback;
514514

515515
LOG_FATAL << "OpenSSL is not found in your system!";
516-
abort();
516+
throw std::runtime_error("OpenSSL is not found in your system!");
517517
#else
518518
if (loop_->isInLoopThread())
519519
{
@@ -547,7 +547,7 @@ void TcpConnectionImpl::startClientEncryption(
547547
(void)sslConfCmds;
548548

549549
LOG_FATAL << "OpenSSL is not found in your system!";
550-
abort();
550+
throw std::runtime_error("OpenSSL is not found in your system!");
551551
#else
552552
if (!hostname.empty())
553553
{

0 commit comments

Comments
 (0)