Boost logo

Boost :

Subject: Re: [boost] [Boost-users] Subject: Formal Review of Proposed Boost.Process library starts tomorrow
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2011-02-08 14:47:22


On Mon, Feb 7, 2011 at 11:38 PM, Ilya Sokolov <ilyasokol_at_[hidden]> wrote:
> On Tue, 08 Feb 2011 02:06:09 +0500, Steven Watanabe <watanabesj_at_[hidden]>
> wrote:
>
>> AMDG
>>
>> Review part 2: implementation
>>
>> [snip]
>>
>> boost/process/config.hpp:
>>
>> Can you use BOOST_THROW_EXCEPTION instead
>> of rolling your own file/line info?
>
> I think BOOST_PROCESS_SOURCE_LOCATION is my piece of code,
> which was written because BOOST_THROW_EXCEPTION didn't work
> (IIRC, there was a problem with BOOST_CURRENT_FUNCTION)

I'm not aware of any problems with BOOST_THROW_EXCEPTION or
BOOST_CURRENT_FUNCTION. I'd suggest deriving the exception types from
boost::exception, and using boost::error_info to indicate things like
which system function failed, and any relevant information like
executable file name:

struct process_system_error: virtual boost::system::system_error,
virtual boost::exception { };

BOOST_THROW_EXCEPTION(process_system_error()<<boost::errinfo_api_function("CreateProcess()")<<boost::errinfo_file_name(exe.get()));

This not only makes the error info available for the user at the catch
site, it'll also show up automatically in the string returned by
boost::diagnostic_information()/current_exception_diagnostic_information(),
along with the throw location, etc.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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