NAME
XS::STL::ErrorCode - Perl binding for C++ STL's std::error_code.
SYNOPSIS
my $err = SomeFramework->some_method();
if ($err) {
say $err;
say $err->value;
say $err->category->name;
say $err->message;
}
DESCRIPTION
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.
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.
API
new($code, $category)
Creates error code object from code and category. Normally you should not create these objects from perl.
value()
Returns error code value (integer)
category()
Returns error code category as XS::STL::ErrorCategory object
message()
Returns error message
operator bool
Returns true if object contains error
operator ""
Stringifies to something like "<message>(<code>:<category>)", for example "Permission denied (13:generic)"
operator ==, eq
If second operand is a XS::STL::ErrorCode
object, compares code values and categories.
If second operand is a number, then compares only code value with that number.
If second operand is something else, return false
List of STL's error codes and categories
Categories (XS::STL::ErrorCategory
objects):
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::*
-
XS::STL::errc::address_family_not_supported XS::STL::errc::address_in_use ...
See C++
std::errc
docs for full list and explanationPlease 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). - XS::STL::future_errc::*
AUTHOR
Pronin Oleg <syber@crazypanda.ru>, Crazy Panda LTD
LICENSE
You may distribute this code under the same terms as Perl itself.