Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2003-01-13 10:07:54


From: "Martin Brown" <martin_w_brown_at_[hidden]>
> Hi,
>
> I would second the approach below. If I can get to
> the native error code, then I can use FormatMessage()
> or strerror() to get to the platform error message,
> localised if necessary. I am not so interested in
> the name of the function throwing the exception - I
> tend to use a logger with a stack-trace built in.

The purpose of the function name is to act as a portable unique identifier
that answers the "what failed?" question; the error code answers the "why
did it fail?" question. Both parts are needed, in general, to construct an
error message. I.e.

who() == "std::fopen"
path1() == "foo.txt"
error() == ENOENT (or "ENOENT")

Sample message:

"foo.txt": Open error: No such file or directory

Depending on the situation, one of the "what"/"why" pieces can be encoded in
the exception type (open_error or file_not_found for the above), but it's
still useful to have a common mechanism to obtain them from a single catch
clause.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk