On 7/21/20 8:44 AM, Drone1h wrote:
Hello All,
In phobos/std/process.d, in the ProcessPipes struct, we can see a few
functions which are marked with "nothrow", but which (under some
conditions) throw:
@property File stdout() @safe nothrow
{
if ((_redirectFlags & Redirect.stdout) == 0)
throw new Error("Child process' standard output stream
hasn't "
~"been redirected.");
return _stdout;
}
Would it be possible to explain this, please ? Or point me to some
relevant documentation, please ?
Thank you.
nothrow only pertains to Exceptions, not Errors.
Throwing an Error isn't guaranteed to unwind the stack properly (which
is why it can be done within nothrow), and the program should exit if it
ever happens. An Error is a programming mistake (it should never happen
if you wrote your code correctly), whereas an Exception can happen due
to environmental issues or user input.
-Steve