Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2006-02-17 20:37:00


Beman Dawes <bdawes_at_[hidden]> writes:

> Do other Boosters like the idea of an overall guideline for dealing with
> operating system API error reporting?

Yep.

>
> Guidelines
>
> Unless otherwise specified, the default versions of all Boost library
> functions, except destructors, that call operating system API functions
> should check for API errors and report the occurrence of such errors by
> throwing an exception of type boost::system_error.

or a class derived therefrom.

> Such functions should also have an overload that takes an additional
> argument of type boost::system_error_code& ec. The behavior of this overload
> is the same as the non-overloaded version, except that it does not throw an
> exception on an API error, and it sets ec to the error code reported by the
> operating system, or to 0 if no error is reported.
>
> For functions where the non-overloaded version returns void, the overloaded
> version returns an object of type boost::system_error_code with the same
> value that ec was set to.

Does it worry you that this will potentially expose an implementation
detail of the functions (i.e. that they use a system call) which may
even differ from platform to platform, making code nonportable?

If we do this, system_error_code should probably be a type that checks
at runtime that its value has been inspected, and asserts otherwise.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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