forked from boostorg/exception
Documentation and examples update.
[SVN r54831]
This commit is contained in:
@ -5,28 +5,24 @@
|
||||
|
||||
//This example shows how to add arbitrary data to active exception objects.
|
||||
|
||||
#include <boost/exception.hpp>
|
||||
#include <boost/exception/all.hpp>
|
||||
#include <boost/shared_ptr.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 file_read_error() << errno_info(errno);
|
||||
throw file_read_error() << boost::errinfo_errno(errno);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
typedef boost::error_info<struct tag_file_name,std::string> file_name_info;
|
||||
|
||||
boost::shared_ptr<FILE> file_open( char const * file_name, char const * mode );
|
||||
void file_read( FILE * f, void * buffer, size_t size );
|
||||
|
||||
@ -43,7 +39,7 @@ parse_file( char const * file_name )
|
||||
catch(
|
||||
boost::exception & e )
|
||||
{
|
||||
e << file_name_info(file_name);
|
||||
e << boost::errinfo_file_name(file_name);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user