Boost Exception

Using enable_current_exception() at the Time of the Throw

Here is how cloning can be enabled in a throw-expression (15.1):

#include <boost/exception/enable_current_exception.hpp>
#include <boost/exception/info.hpp>
#include <stdio.h>
#include <errno.h>

typedef boost::error_info<struct tag_errno,int> errno_info;

class file_read_error: public boost::exception { };

void
file_read( FILE * f, void * buffer, size_t size )
    {
    if( size!=fread(buffer,1,size,f) )
        throw boost::enable_current_exception(file_read_error()) <<
            errno_info(errno);
    }

See also: