Skip to content

Commit aafbf4d

Browse files
committed
Merge pull request etr#83 from 4picht/patch-no-abort
Do not call abort, throw an exception instead
2 parents a7d349a + 6e98ee0 commit aafbf4d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/httpserver/webserver.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <deque>
4242

4343
#include <pthread.h>
44+
#include <stdexcept>
4445

4546
#include "httpserver/create_webserver.hpp"
4647

@@ -66,6 +67,15 @@ namespace details {
6667
class comet_manager;
6768
}
6869

70+
class webserver_exception : public std::runtime_error
71+
{
72+
public:
73+
webserver_exception()
74+
: std::runtime_error("httpserver runtime error")
75+
{
76+
}
77+
};
78+
6979
/**
7080
* Class representing the webserver. Main class of the apis.
7181
**/

src/webserver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void* webserver::select(void* self)
280280
FD_ZERO (&ws);
281281
FD_ZERO (&es);
282282
if (MHD_YES != MHD_get_fdset (di->daemon, &rs, &ws, &es, &max))
283-
abort(); /* fatal internal error */
283+
throw ::httpserver::webserver_exception(); /* fatal internal error */
284284

285285
unsigned long long timeout_microsecs = 0;
286286
unsigned long long timeout_secs = 0;
@@ -563,7 +563,7 @@ bool webserver::start(bool blocking)
563563
{
564564
cout << gettext("Unable to connect daemon to port: ") <<
565565
this->port << endl;
566-
abort();
566+
throw ::httpserver::webserver_exception();
567567
}
568568
details::daemon_item* di = new details::daemon_item(this, daemon);
569569
daemons.push_back(di);
@@ -579,7 +579,7 @@ bool webserver::start(bool blocking)
579579
static_cast<void*>(di)
580580
))
581581
{
582-
abort();
582+
throw ::httpserver::webserver_exception();
583583
}
584584
}
585585
}
@@ -595,7 +595,7 @@ bool webserver::start(bool blocking)
595595
{
596596
cout << gettext("Unable to connect daemon to port: ") <<
597597
this->port << endl;
598-
abort();
598+
throw ::httpserver::webserver_exception();
599599
}
600600
details::daemon_item* di = new details::daemon_item(this, daemon);
601601
daemons.push_back(di);

0 commit comments

Comments
 (0)