Boost logo

Boost :

From: Kevin S. Van Horn (kevin.vanhorn_at_[hidden])
Date: 2002-02-22 09:05:44


On Fri, 22 Feb 2002, davlet_panech wrote:

> Hi,
>
> Is there any any interest in a runtime_error subclass constructible
> from an errno value, such that the description returned by `what()'
> is created using a call to strerror()? I think such class could be
> useful for at least some of the existing boost libraries, such as
> Boost.Threads, or the Socket library (which doesn't exist yet, but
> still):
>
> class sys_error: public std::runtime_error {
> public:
> sys_error( const std::string &s ): runtime_error( s )
> {
> }
> };

I like the idea. The only problem I see is that although most of the error
codes should translate to runtime_error exceptions, there are some that
should translate to logic_error exceptions (problems arising from
programmer error -- e.g., EBADF (invalid descriptor)).

>
> class specfic_sys_error: public sys_error
> {
> public:
>
> // Pass strerror( errno ) to base class ctor
> specific_sys_error();
>
> // Pass strerror( errno_val ) to base ctor
> specific_sys_error( int errno_val );
>
> // Create error description "perror-style", i.e.,
> // details << ": " << strerror( errno );
> template< class T >
> specific_sys_error( const T &details, int errno )
>
> };
>
> // Possibly a few subclasses at least for some
> // of the errno values (ENOENT & EACCESS are good
> // candidates IMHO).
>
> Thanks,
> D.P.
>
>
>
> Info: http://www.boost.org Send unsubscribe requests to: <mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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