About
For different situations different error classes exist. These different classes help to identify the nature of the error and allow to store additional information.
Built-in Types
The default error types are defined in the core.framework.
- Note
- In other frameworks various specialized error types exist.
-
To check the type of a given error one can use maxon::IsErrorOfType().
Errors about incorrect function arguments:
Errors about incorrect function implementations:
Errors about incorrect program flow:
Specialised Errors:
General Errors:
{
{
if (number >= 0)
{
}
else
{
}
}
if (agg.GetCount())
return agg;
}
Py_ssize_t i
Definition: abstract.h:645
Py_ssize_t count
Definition: abstract.h:640
Definition: errorbase.h:126
Definition: basearray.h:412
MAXON_ATTRIBUTE_FORCE_INLINE Int GetCount() const
Definition: basearray.h:573
Definition: string.h:1235
Int64 Int
signed 32/64 bit int, size depends on the platform
Definition: apibase.h:188
float Float32
32 bit floating point value (float)
Definition: apibase.h:182
return OK
Definition: apibase.h:2690
MAXON_ATTRIBUTE_FORCE_INLINE Float32 Sqrt(Float32 val)
Calculates square root of a value. Note that the input must not be be negative, so that no exceptions...
Definition: apibasemath.h:266
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
#define FormatString(...)
Definition: string.h:2100
#define iferr_scope
Definition: resultbase.h:1384
#define iferr_return
Definition: resultbase.h:1519
{
const maxon::Error
error =
res.GetError();
{
for (const maxon::Error subError : agg)
{
}
}
}
PyObject * error
Definition: codecs.h:206
Py_UCS4 * res
Definition: unicodeobject.h:1113
#define DiagnosticOutput(formatString,...)
Definition: debugdiagnostics.h:176
static const ERROR_FAILED FAILED
Definition: resultbase.h:68
Custom Error
All error types are based on maxon::ErrorInterface. It is possible to create custom error types based on that interface. See also Interface Basics.
A custom error interfaces is based on the maxon::ErrorInterface (see Error Class):
{
public:
{
*static_cast<typename S::DirectlyReferencedType::Hxx1::ReferenceClass*>(this) = S::DirectlyReferencedType::Hxx1::ErrObj::GetInstance()();
typename S::DirectlyReferencedType::Ptr
e = this->MakeWritable(
false).GetPointer();
e.SetCustomErrorCode(errorCode);
}
);
};
[error_custom_interface]
Definition: customerror.h:14
MAXON_METHOD maxon::Int GetCustomErrorCode() const
MAXON_METHOD void SetCustomErrorCode(maxon::Int errorCode)
MAXON_INTERFACE(ExampleErrorInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxonexample.error.example")
MAXON_ADD_TO_COPY_ON_WRITE_REFERENCE_CLASS(void Create(MAXON_SOURCE_LOCATION_DECLARATION, maxon::Int errorCode) { *static_cast< typename S::DirectlyReferencedType::Hxx1::ReferenceClass * >(this)=S::DirectlyReferencedType::Hxx1::ErrObj::GetInstance()();typename S::DirectlyReferencedType::Ptr e=this->MakeWritable(false).GetPointer();e.SetLocation(MAXON_SOURCE_LOCATION_FORWARD);e.SetCustomErrorCode(errorCode);})
static auto Create(ARGS &&... args)
Definition: apibase.h:2773
#define MAXON_SOURCE_LOCATION_FORWARD
Definition: memoryallocationbase.h:84
#define MAXON_REFERENCE_COPY_ON_WRITE(FREEIMPL)
Definition: interfacebase.h:1212
#define MAXON_METHOD
Definition: interfacebase.h:1001
#define MAXON_INTERFACE_BASES(...)
Definition: objectbase.h:1062
#define MAXON_SOURCE_LOCATION_DECLARATION
Definition: memoryallocationbase.h:77
Py_ssize_t * e
Definition: longobject.h:89
The registration or implementation of the custom error type can be simplified with these macros:
- ::MAXON_ERROR_REGISTERX: Registers the implementation and publishes the error object.
- MAXON_ERROR_IMPLEMENT_AND_REGISTER: Implements and registers a whole error interface that does not introduce additional methods.
class ExampleErrorImpl :
public maxon::Component<ExampleErrorImpl, ExampleErrorInterface>
{
public:
{
_errorCode =
src._errorCode;
}
public:
{
}
{
_errorCode = errorCode;
}
{
return _errorCode;
}
private:
};
Definition: objectbase.h:2651
PyObject * src
Definition: abstract.h:305
@ NORMAL
Samples the surface as the user moves over it the SculptObject and returns a new hit point and normal...
#define MAXON_COMPONENT(KIND,...)
Definition: objectbase.h:2212
#define MAXON_COMPONENT_OBJECT_REGISTER(C,...)
Definition: objectbase.h:2473
The new error type can now easily be used:
Further Reading