[Issue 2545] write(f)(ln) delays throwing StdioException("Bad file descriptor") when no console is available

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Dec 29 08:21:19 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2545


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com
            Summary|write(f)(ln) throws         |write(f)(ln) delays throwing
                   |StdioException("Bad file    |StdioException("Bad file
                   |descriptor") when no console|descriptor") when no console
                   |is available                |is available




------- Comment #1 from smjg at iname.com  2008-12-29 10:21 -------
How can it never fail at all?  Or are you confusing "fail" with "throw an
exception"?

In any case, failing silently is completely the wrong approach.  If there is no
stdout to write to, it should throw an immediate exception.  That's what
exceptions are there for.

printf doesn't suppress errors.  It returns a value that indicates success or
failure.  This is because C doesn't have exception handling, and so C functions
have to improvise.  In D, OTOH, the only right thing to do is use exceptions to
indicate failure.
http://www.digitalmars.com/d/1.0/errors.html


-- 



More information about the Digitalmars-d-bugs mailing list