Debian Codegraph @

docs/source/errors.rst

raw
1 Error reporting
2 ===============
3
4 In addition to `cppy::ptr`, cppy provides a set of convenience functions for
5 reporting errors which all return a NULL pointer allowing them to be used as
6 follows:
7
8 .. code:: c++
9
10 PyObject* function( PyObject* obj )
11 {
12 cppy::ptr obj_ptr( cppy::incref( obj ) );
13 if( !obj_ptr.is_bool() )
14 return type_error( obj_ptr.get(), "bool" );
15 return obj_ptr.get();
16 }
17
18 Functions
19 ---------
20
21 Functions taking two arguments provide sensible pre-formatted error messages.
22
23 .. code:: c++
24
25 inline PyObject* system_error( const char* message )
26
27 inline PyObject* type_error( const char* message )
28
29 inline PyObject* type_error( PyObject* ob, const char* expected )
30
31 inline PyObject* value_error( const char* message )
32
33 inline PyObject* runtime_error( const char* message )
34
35 inline PyObject* attribute_error( const char* message )
36
37 inline PyObject* attribute_error( PyObject* ob, const char* attr )