Hi, How can I interpret and use the error_code in my application? As an example my ASIO async_read "handler function" receives one argument as error, as shown below void MyClass::AsyncReadHandler(const boost::system::error_code& error,std::size_t bytes_transferred) { } How can I inrterpret the "error" in a meaningful way? error.message() returns the meaning of the error and and error.value() returns an integer code associated with the error. So far fine, but how can I use it in a comparison operator in a portable way... if(error.value()==2) //Not readable { } if(error.value()==END_OF_FILE) //More readable { } So how can I get the respective "enum" associated with the error Thanks a lot, Lloyd ______________________________________ Scanned and protected by Email scanner
On 1 July 2010 22:32, Lloyd
Hi,
How can I interpret and use the error_code in my application?
As an example my ASIO async_read "handler function" receives one argument as error, as shown below
void MyClass::AsyncReadHandler(const boost::system::error_code& error,std::size_t bytes_transferred) { }
[...]
So how can I get the respective "enum" associated with the error
Thanks a lot, Lloyd
Hi Lloyd, I think you mean: if (error == boost::asio::error::operation_aborted) {...} see Boost\include\boost-1_43\boost\asio\error.hpp for the asio enums (and how to add your own errors).
De : boost-users-bounces@lists.boost.org [mailto:boost-users-
How can I interpret and use the error_code in my application?
Chris Kohlhoff wrote a series of blog posts on the topic: http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-1.html
if(error.value()==2) //Not readable { }
if(error.value()==END_OF_FILE) //More readable { }
So how can I get the respective "enum" associated with the error
Look at boost::system::errc in boost/system/error_code.hpp
Thanks for this useful link. I have checked boost::system::error,
boost::asio::error, but could not find a solution to my problem.
I am writing to a file using async_write_some(). If an error occurs, how can
check whether the disk is full or not? A one or two line code will be very
useful.
Thanks a lot,
Lloyd
----- Original Message -----
From: "Eric MALENFANT"
De : boost-users-bounces@lists.boost.org [mailto:boost-users-
How can I interpret and use the error_code in my application?
Chris Kohlhoff wrote a series of blog posts on the topic: http://blog.think-async.com/2010/04/system-error-support-in-c0x-part-1.html
if(error.value()==2) //Not readable { }
if(error.value()==END_OF_FILE) //More readable { }
So how can I get the respective "enum" associated with the error
Look at boost::system::errc in boost/system/error_code.hpp
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
______________________________________ Scanned and protected by Email scanner
De: Lloyd
Thanks for this useful link. I have checked boost::system::error, boost::asio::error, but could not find a solution to my problem.
I am writing to a file using async_write_some(). If an error occurs, how can check whether the disk is full or not? A one or two line code will be very useful.
Something like (warning, untested): void write_handler(const boost::system::error_code& ec, std::size_t bytes_transferred) { if (ec == boost::system::errc::no_space_on_device){ // ...
Something like (warning, untested):
void write_handler(const boost::system::error_code& ec, std::size_t bytes_transferred) { if (ec == boost::system::errc::no_space_on_device){ // ...
Thanks a lot, I will test the code... Thank you very much, Lloyd ______________________________________ Scanned and protected by Email scanner
participants (3)
-
Eric MALENFANT
-
liamv7
-
Lloyd