About
The error reporting system of the MAXON API is based on the maxon::Result template. Such a maxon::Result object can contain both the actual return value of the function and an error object if an error had occurred.
Result
These default error values are used to check if a maxon::Result object contains an error or not:
- Note
- maxon::OK can be used as a return value. But it is not possible to use maxon::FAILED as a return value. A proper error object must be returned instead.
-
The return value of a function returning maxon::Result<void> should be documented as "OK on success".
{
if (number == nullptr)
*number = *number + 1;
}
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:202
return OK
Definition: apibase.h:2735
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
Result Class
A maxon::ResultBase / maxon::Result object stores the return value and the error returned by a function.
The stored value and error are accessed with:
- Note
- Typically errors should be handled with iferr_scope and iferr_return, see Error Handling.
{
}
{
const maxon::Error
error =
res.GetError();
}
Definition: string.h:1237
PyObject * error
Definition: codecs.h:206
Py_UCS4 * res
Definition: unicodeobject.h:1113
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:170
static const ERROR_FAILED FAILED
Definition: resultbase.h:68
Special Classes
For special situations these specialized return values exist:
{
}
class PrintNumbers
{
public:
{
};
{
};
};
Definition: resultbase.h:193
PyFrameObject * f
Definition: ceval.h:26
Float64 Float
Definition: apibase.h:211
#define iferr_scope
Definition: resultbase.h:1389
#define iferr_return
Definition: resultbase.h:1524
Further Reading