April 13, 2005 Re: std.syserror could use a bit of tidying up | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote: <snip> >>2. Turn SysError into an exception class. >>What do people think we should do? > > I like option 2 except that it feels dangerous to tie the inheritance tree to platform-specific support of error codes or strings. Off the top of my head perhaps SysError needs to get merged with Exception (copied from my proposed Exception in a previous post): > class Exception { > char[] msg; > Object cause; > this(char[] msg, Object cause = null); > void print(); // print this exception and any causes > char[] toString(); // string summarizes this exception > bit hasSysCode(out int code); > bit hasSysMsg(out char[] msg); > } <snip> What would cause be under this idea? And the forms of hasSysCode and hasSysMsg don't seem right. Why should we be forced to supply a dummy variable just to see whether a system error code exists? I'm more inclined towards something like bit hasSysCode(); int sysErrorCode(); char[] sysErrorMessage(); The last of these could return null if there is no system error code to translate. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
April 13, 2005 Re: std.syserror could use a bit of tidying up | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath wrote: > Assimilating this thread I have produced the attached code. > Comments? I see, except that I don't see: - a SystemError constructor that does the interrogation as per systemError() - any room for a context message - or have you decided this should be left to the class that chains with it whatever that may be? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
April 13, 2005 Re: std.syserror could use a bit of tidying up | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message news:d3inne$190v$1@digitaldaemon.com... > Ben Hinkle wrote: > <snip> >>>2. Turn SysError into an exception class. >>>What do people think we should do? >> >> I like option 2 except that it feels dangerous to tie the inheritance >> tree to platform-specific support of error codes or strings. Off the top >> of my head perhaps SysError needs to get merged with Exception (copied >> from my proposed Exception in a previous post): >> class Exception { >> char[] msg; >> Object cause; >> this(char[] msg, Object cause = null); >> void print(); // print this exception and any causes >> char[] toString(); // string summarizes this exception >> bit hasSysCode(out int code); >> bit hasSysMsg(out char[] msg); >> } > <snip> > > What would cause be under this idea? I prefer Regan's solution. Please ignore my suggestion above - it was made without reading all other other posts. |
April 14, 2005 Re: std.syserror could use a bit of tidying up | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | On Wed, 13 Apr 2005 10:14:15 +0100, Stewart Gordon <smjg_1998@yahoo.com> wrote: > Regan Heath wrote: >> Assimilating this thread I have produced the attached code. >> Comments? > > I see, except that I don't see: > > - a SystemError constructor that does the interrogation as per systemError() That's a good idea. > - any room for a context message - or have you decided this should be left to the class that chains with it whatever that may be? Yes. Regan |
Copyright © 1999-2021 by the D Language Foundation