Discussion:
[Wt-interest] Does WServer::start() ever return false (was: Re: Silent failure of server start-up? WServer error handling)
K. Frank
2016-11-03 21:55:44 UTC
Permalink
Hello List!

Does WServer::start() ever return false, or does it always signal
error conditions by throwing exceptions?

I find the documentation either contradictory or ambiguous.


Thanks.
Hello List!
(This is wt-3.3.3 compiled with mingw-w64 on windows 7.)
...
My second questions is about the WServer documentation and
error handling.
WTCONNECTOR_API bool Wt::WServer::start()
Starts the server in the background.
Returns whether the server could be successfully started.
Exceptions
Exception: indicates a problem starting the server.
This seems to be saying that when WServer::start() encounters
an error (regardless of whether my above example counts as
an error), the error condition is reported by returning false and
by throwing an exception. Of course, you can't actually do
both.
Are there two different classes of WServer::start() errors (maybe
for historical reasons), some of which are reported with a false
return value, and others that are reported with a thrown exception?
Anyway, what are the recommended best practices for handling
WServer::start() error conditions?
Thanks.
K. Frank
Wim Dumon
2016-11-07 12:05:53 UTC
Permalink
Hey Frank,

After reviewing the documentation, I have to admit your remark is correct:
the documentation is confusing.

In reality, most errors will be reported by throwing exceptions.

If the server was already running, start() will return false, and (for
wthttp) if the server does not have to be stopped because Wt was compiled
without thread support (and the server will thus execute in the context of
the main thread), start() will also return false.

I believe we should document the return value of start() as indication of
the need of calling stop(): if start() returns true, the server has to be
stopped by calling stop(). If start() returns false, no extra instance of
the server is running. I'm not sure if all connectors correctly implement
this behaviour at this point, though.

Best regards,
Wim.
Post by K. Frank
Hello List!
Does WServer::start() ever return false, or does it always signal
error conditions by throwing exceptions?
I find the documentation either contradictory or ambiguous.
Thanks.
Post by K. Frank
Hello List!
(This is wt-3.3.3 compiled with mingw-w64 on windows 7.)
...
My second questions is about the WServer documentation and
error handling.
WTCONNECTOR_API bool Wt::WServer::start()
Starts the server in the background.
Returns whether the server could be successfully started.
Exceptions
Exception: indicates a problem starting the server.
This seems to be saying that when WServer::start() encounters
an error (regardless of whether my above example counts as
an error), the error condition is reported by returning false and
by throwing an exception. Of course, you can't actually do
both.
Are there two different classes of WServer::start() errors (maybe
for historical reasons), some of which are reported with a false
return value, and others that are reported with a thrown exception?
Anyway, what are the recommended best practices for handling
WServer::start() error conditions?
Thanks.
K. Frank
------------------------------------------------------------
------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
witty-interest mailing list
https://lists.sourceforge.net/lists/listinfo/witty-interest
K. Frank
2016-11-07 17:52:15 UTC
Permalink
Hi Wim!
Post by Wim Dumon
Hey Frank,
the documentation is confusing.
In reality, most errors will be reported by throwing exceptions.
If the server was already running, start() will return false, and (for
wthttp) if the server does not have to be stopped because Wt was compiled
without thread support (and the server will thus execute in the context of
the main thread), start() will also return false.
Okay, that makes sense.
Post by Wim Dumon
I believe we should document the return value of start() as indication of
the need of calling stop(): if start() returns true, the server has to be
stopped by calling stop(). If start() returns false, no extra instance of
the server is running.
Thanks for clearing all that up for me. (It also makes clear to me what
was going on in some of the sample code I was looking at.)
Post by Wim Dumon
I'm not sure if all connectors correctly implement
this behaviour at this point, though.
Best regards,
Wim.
Thanks.


K. Frank
Post by Wim Dumon
Post by K. Frank
Hello List!
Does WServer::start() ever return false, or does it always signal
error conditions by throwing exceptions?
...
Loading...