Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,634 of 33,346    |
|    Martin B. to Castor Nageur    |
|    Re: Looking for an elegant way to conver    |
|    07 Nov 11 11:50:17    |
      ae2f5541       From: 0xCDCDCDCD@gmx.at              On 05.11.2011 00:26, Castor Nageur wrote:       > On 4 nov, 09:34, "Martin B."<0xCDCDC...@gmx.at> wrote:       >       >> Believe me, I know your problem all too well, but there is really no       >> medium to long term benefit in error masking.       >       > I don't want to mask errors but just returning them instead of       > throwing them.       >              I had missed the out-argument style in your original example.               void mynewclass::mynewmethod(        ... /* API method arguments */,        int &err        )              If you (have to) follow this route, all I can additionally suggest is to       *not* use `int` for the error code. Don't do it!       The simplest option would be to just use an `APIException` object as out       parameter (e.g. like the MFC CFile class does with its Open function).              More involved solutions could be a compromise on Daniel Krügler's proposal:              > make error-code based more robust       > against other resistant coworkers that       > tend to ignore to check these error values:       > Just invent a class type       > that behaves like an error code value,       > but recognices whether its value       > has been read or not. In the destructor       > of this wrapper check for reading ...              If you just add a debug assert, programmers that ignore the error codes       would be caught in debug builds and for release builds you'll ...              > but my boss asked me to wrap the exception       > throwing code so errors are returned and       > not thrown anymore.       > It seems that many people dislike exceptions              ... have the "undefined" behaviour your boss seems to wish for.       ( *Sigh*, don't I just know these arguments from somewhere ... :-) )              cheers,       Martin              --       I'm here to learn, you know.       Just waiting for someone,       to jump from the shadows,       telling me why I'm wrong.                      [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca