On 24/09/2020 21:13, Frederick Gotham wrote:
>
> I've recently started doing web GUI programming.
>
> On the web server, I have a PHP script that uses the "exec" function
> to run my C++ program.
Why don't you just run it from the web-server?
> My C++ program performs two HTTPS requests, and depending on the data
> it gets back, it might perform 2 or 3 more HTTPS requests. My program
> then prints HTML code to stdout. The PHP script takes this HTML and
> throws it up on the end user's screen as a webpage.
Same question...
> My C++ program could fall down in several ways. Any of the HTTPS
> requests could fail, or return partial (or corrupt) data. There could
> be an uncaught exception from the networking code, or a segfault in a
> 3rd party library. It could fail in lots of ways.
>
> My C++ code at the moment is quite clean, and I don't want to litter
> it with error-handling code.
Bad call. Error handling should be part of the design (and tested).
> One thing I could do is throw an "std::runtime_error" whenever
> anything goes wrong, then let these exceptions propagate up to
> 'main', and then in 'main' just restart the whole program.
Not an uncommon approach.
Your code should handle its errors and pass any failures back to the
web-server.
--
Ian.