The MStatus class can determine if a method has failed.
Many API methods either return an instance of the MStatus class, or fill in an instance passed as an optional parameter. The MStatus class contains the methods error, and an overloaded operator bool, both of which return false if the instance is holding an error status. This means
you can check the success of a call quickly, for example:
If the MStatus instance contains an error, you can do one of several things:
- Use the statusCode method to retrieve an element of the MStatusCode enum that indicates the reason for the failure.
- Use the errorString method to retrieve an MString containing a detailed description of the error.
- Use the perror method to print the detailed description of the error to standard error,
optionally pre-pended by a string you provide.
- Use the overloaded equality and inequality operators to compare the instance to a
- Reset the instance to the successful state with the clear method.