www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Phobos SysError...

reply Regan Heath <regan netwin.co.nz> writes:
I just noticed the undocumented? SysError class in phobos. It appears to 
be for getting the OS error message associated with an error code.

It is currently a switch statement with some errno constants and constant 
strings.

I think it should be updated to call FormatMessage on windows and strerror 
on *NIX. Attached is my attempt at it, if it meets aproval pls consider it 
for inclusion in Phobos.

Regan.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 2004
next sibling parent reply Regan Heath <regan netwin.co.nz> writes:
I forgot to mention, the Windows functions I needed (FormatMessageA and 
LocalFree) are not declared in std.c.windows.windows, or aywhere else I 
could find.

Is this because they are defined in winbase.h and no-one has done a D stub 
for that yet?

I have declared them in the attached syserror.d but they should be moved.

The attached file may not work on *NIX it may require something like
   extern (C) char *strerror(int errnum);
I'm not sure.

Regan

On Fri, 23 Jul 2004 00:33:48 +1200, Regan Heath <regan netwin.co.nz> wrote:
 I just noticed the undocumented? SysError class in phobos. It appears to
 be for getting the OS error message associated with an error code.

 It is currently a switch statement with some errno constants and constant
 strings.

 I think it should be updated to call FormatMessage on windows and 
 strerror
 on *NIX. Attached is my attempt at it, if it meets aproval pls consider 
 it
 for inclusion in Phobos.

 Regan.
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 2004
next sibling parent Regan Heath <regan netwin.co.nz> writes:
<g> I always forget to polish my code.. this version has a few fixes, like 
the removal of the newline from the error string, and the addition of the 
extern (C) char *strerror(int) etc.

Regan

On Fri, 23 Jul 2004 00:40:53 +1200, Regan Heath <regan netwin.co.nz> wrote:
 I forgot to mention, the Windows functions I needed (FormatMessageA and 
 LocalFree) are not declared in std.c.windows.windows, or aywhere else I 
 could find.

 Is this because they are defined in winbase.h and no-one has done a D 
 stub for that yet?

 I have declared them in the attached syserror.d but they should be moved.

 The attached file may not work on *NIX it may require something like
    extern (C) char *strerror(int errnum);
 I'm not sure.

 Regan

 On Fri, 23 Jul 2004 00:33:48 +1200, Regan Heath <regan netwin.co.nz> 
 wrote:
 I just noticed the undocumented? SysError class in phobos. It appears to
 be for getting the OS error message associated with an error code.

 It is currently a switch statement with some errno constants and 
 constant
 strings.

 I think it should be updated to call FormatMessage on windows and 
 strerror
 on *NIX. Attached is my attempt at it, if it meets aproval pls consider 
 it
 for inclusion in Phobos.

 Regan.
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 2004
prev sibling parent "Matthew" <admin.hat stlsoft.dot.org> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opsbjhifhn5a2sq9 digitalmars.com...
 I forgot to mention, the Windows functions I needed (FormatMessageA and
 LocalFree) are not declared in std.c.windows.windows, or aywhere else I
 could find.
They're included with WindowsException (with various useful techniques for loading string messages from different modules), which Walter's been hanging onto for several months, but is still not in Phobos. I'm still waiting ... sigh ...
 Is this because they are defined in winbase.h and no-one has done a D stub
 for that yet?

 I have declared them in the attached syserror.d but they should be moved.

 The attached file may not work on *NIX it may require something like
    extern (C) char *strerror(int errnum);
 I'm not sure.
 Regan

 On Fri, 23 Jul 2004 00:33:48 +1200, Regan Heath <regan netwin.co.nz> wrote:
 I just noticed the undocumented? SysError class in phobos. It appears to
 be for getting the OS error message associated with an error code.

 It is currently a switch statement with some errno constants and constant
 strings.

 I think it should be updated to call FormatMessage on windows and
 strerror
 on *NIX. Attached is my attempt at it, if it meets aproval pls consider
 it
 for inclusion in Phobos.

 Regan.
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 23 2004
prev sibling parent reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Nice. Do you mind if I pop this into Mango until the 'official' version
appears? (with credit of course).

- Kris

"Regan Heath" <regan netwin.co.nz> wrote in message
news:opsbjg6mt85a2sq9 digitalmars.com...
 I just noticed the undocumented? SysError class in phobos. It appears to
 be for getting the OS error message associated with an error code.

 It is currently a switch statement with some errno constants and constant
 strings.

 I think it should be updated to call FormatMessage on windows and strerror
 on *NIX. Attached is my attempt at it, if it meets aproval pls consider it
 for inclusion in Phobos.

 Regan.

 --
 Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 2004
parent Regan Heath <regan netwin.co.nz> writes:
Not at all, go right ahead.
:)

On Thu, 22 Jul 2004 10:15:18 -0700, Kris 
<someidiot earthlink.dot.dot.dot.net> wrote:

 Nice. Do you mind if I pop this into Mango until the 'official' version
 appears? (with credit of course).

 - Kris

 "Regan Heath" <regan netwin.co.nz> wrote in message
 news:opsbjg6mt85a2sq9 digitalmars.com...
 I just noticed the undocumented? SysError class in phobos. It appears to
 be for getting the OS error message associated with an error code.

 It is currently a switch statement with some errno constants and 
 constant
 strings.

 I think it should be updated to call FormatMessage on windows and 
 strerror
 on *NIX. Attached is my attempt at it, if it meets aproval pls consider 
 it
 for inclusion in Phobos.

 Regan.

 --
 Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 2004