XS::STL::ErrorCode - Perl binding for C++ STL's std::error_code.
my $err = SomeFramework->some_method(); if ($err) { say $err; say $err->value; say $err->category->name; say $err->message; }
This binding is intended for use from XS modules that returns errors as std::error_code objects to perl. It provides them with typemap for std::error_code and Perl interface.
std::error_code
This module comes with interface to all defined error codes and categories in STL. Usually XS modules make use of both STL's categories and custom categories, see certain module docs for details.
Creates error code object from code and category. Normally you should not create these objects from perl.
Returns error code value (integer)
Returns error code category as XS::STL::ErrorCategory object
Returns error message
Returns true if object contains error
Stringifies to something like "<message>(<code>:<category>)", for example "Permission denied (13:generic)"
If second operand is a XS::STL::ErrorCode object, compares code values and categories.
XS::STL::ErrorCode
If second operand is a number, then compares only code value with that number.
If second operand is something else, return false
Categories (XS::STL::ErrorCategory objects):
XS::STL::ErrorCategory
Error code constants are XS::STL::ErrorCode objects, not just code values. So that
if ($err == XS::STL::errc::address_family_not_supported)
compares both code value and category.
XS::STL::errc::address_family_not_supported XS::STL::errc::address_in_use ...
See C++ std::errc docs for full list and explanation
std::errc
Please note, some of values might be not available, if the C++ compiler does not export them (e.g. no_message on gcc/mingw on Windows).
no_message
Pronin Oleg <syber@crazypanda.ru>, Crazy Panda LTD
You may distribute this code under the same terms as Perl itself.
To install XS::Framework, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XS::Framework
CPAN shell
perl -MCPAN -e shell install XS::Framework
For more information on module installation, please visit the detailed CPAN module installation guide.