[ros-kernel] Re: Enhanced error messages

Martin Fuchs martin-fuchs at gmx.net
Sun Jan 11 10:07:27 CET 2004


> > >  a fine bet that GetLastError() == ERROR_INSUFFICIENT_BUFFER after that,
> > >  which again would destroy the extended information.  In 
> > addition, you have
> > 
> > This would be a design flaw in FormatMessage() itself. Could also 
> > be dealed
> > with since we write out own version.
> That's not a design flaw, it's the way the API works.  FormatMessage can
>  fail, like any other API function, and needs to report errors when it does.

Please don't take me wrong. It is no design flaw in the current FormatMessage()
interface, yes. It would be one in the new, enhanced version.

> > > to consider where the storage for this information is coming from --
> > > seemingly it would have to be some TLS as the last error number 
> > > itself is,
> > > and that implies extra weight per thread.
> > > Alternately, it implies allocating memory at each 
> > > failure, which is more weight again.
> > 
> > It's just one pointer more per thread, and a string copy in case 
> > of some errors.
> > I think this won't hurt compared to the gain of better error messages.
> > 
> It's more than just a pointer: you have to store potentially a number of
> previous errors (to work around other API calls inbetween the error
> occurring and FormatMessage) _and_ the filename/object path associated with
> each one.  You can't just store a pointer to the user's filename buffer as
> this may not be valid by the time you get around formatting the message.  In
> particular, this is likely to be the case for the kind of application that
> is lazy about its error reporting.

I don't want to propose a perfect error management API. That's the responsibility
of the application itself.
I just would like to propose a (small) tweak to store important error information.
It would not hurt very much in respect to performance, since most of the new
code would only be executed in error paths.
And the only change to WIN32 API, the error string returned from FormatMessage()
{Yes, I want to break a bit with holy compatibility.} are also not very big


More information about the Ros-kernel mailing list