Difference between revisions of "IC Python API:RLPy RStatus"

From Reallusion Wiki!
Jump to: navigation, search
m
m
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
== Detailed Description ==
+
{{last_modified}}
This class is used for API level error handling.
+
 
Most API methods return this class as a return value. The developer
+
== Description ==
can query, clear, print the error code along with the error description.
+
 
 +
This class facilitates error handling for each API.  It encapsulates the status code as a return value for each API function. Developers can query, set, or output status codes through this class.  The RStatus codes and their instructions are listed below:
 +
 
 +
{| class="wikitable"
 +
!Constant
 +
!Value
 +
|-
 +
|RStatus.Success
 +
|The operation was successful.
 +
|-
 +
|RStatus.Failure
 +
|The operation failed.
 +
|-
 +
|RStatus.InsufficientMemory
 +
|The operation failed due to insufficient memory.
 +
|-
 +
|RStatus.LicenseFailure
 +
|Application is not licensed for the attempted operation.
 +
|-
 +
|RStatus.IncompatibleVersion
 +
|The applied operation is not compatible with the current version.
 +
|-
 +
|RStatus.InvalidParameter
 +
|An invalid parameter was provided.
 +
|-
 +
|RStatus.UnknownParameter
 +
|The operation was called with an unrecognized argument.
 +
|-
 +
|RStatus.NotImplemented
 +
|This operation has not been implemented.
 +
|-
 +
|RStatus.Deprecated
 +
|This operation has been deprecated.
 +
|-
 +
|RStatus.NotFound
 +
|Not currently used.
 +
|-
 +
|RStatus.EndOfFile
 +
|Not currently used.
 +
|}
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 
status = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
 
status = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
 
+
 
 
if status == RLPy.RStatus.Success:
 
if status == RLPy.RStatus.Success:
print("sucess") # print sucess
+
    print("sucess")                                 # print sucess
 +
 
 +
if status == RLPy.RStatus.Failure:
 +
    print("failure")
 +
    status.Clear()
 +
    print(status.IsError())                        # False
 +
 
 +
if status.GetStatusCode() == RLPy.RStatus.Success:
 +
    print("sucess")                                # print sucess
 +
 
 +
print(status.IsError())                           
 +
</syntaxhighlight>
  
if status:
+
== Member Functions ==
print("sucess") # print sucess
+
  
if status.GetStatusCode() == RLPy.RStatus.Success:
+
=== Clear( self ) ===
print("sucess") # print sucess
+
 
 +
Clear the current error status. '''Success''' status code is returned upon calling this function.
 +
 
 +
See also: [[#IsError( self )|IsError( self )]]
  
print(status.IsError()) # print false
 
</syntaxhighlight>
 
==Constructor & Destructors==
 
===__init__===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RStatus.__init__ ( self, args )
+
status = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
 +
if status == RLPy.RStatus.Failure:
 +
    print("failure")
 +
    status.Clear()
 +
    print(status.IsError()) # False
 
</syntaxhighlight>
 
</syntaxhighlight>
The copy constructor of the class.
 
Initialize a new RStatus object with the values from another RStatus object.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''status''' [IN] The target RStatus object.
+
=== GetStatusCode ( self ) ===
</div>
+
 
==Member Functions==
+
Get the current status code.  Refer to the status code table above.
===Clear===
+
 
 +
==== Returns ====
 +
:Return the internal status code - int
 +
*RLPy.RStatus.Success
 +
*RLPy.RStatus.Failure
 +
*RLPy.RStatus.InsufficientMemory
 +
*RLPy.RStatus.LicenseFailure
 +
*RLPy.RStatus.IncompatibleVersion
 +
*RLPy.RStatus.InvalidParameter
 +
*RLPy.RStatus.UnknownParameter
 +
*RLPy.RStatus.NotImplemented
 +
*RLPy.RStatus.Deprecated
 +
*RLPy.RStatus.NotFound
 +
*RLPy.RStatus.EndOfFile
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RStatus.Clear ( self )
+
if status.GetStatusCode() == RLPy.RStatus.Success:
 +
    print("sucess")                                 # print sucess
 
</syntaxhighlight>
 
</syntaxhighlight>
Clear error codes from the RStatus instance.
 
After this call, it will behave as if it contained Success.
 
-----
 
===GetStatusCode===
 
<syntaxhighlight lang="Python">
 
RLPy.RStatus.GetStatusCode ( self )
 
</syntaxhighlight>
 
Retrieve the type of error that occurred, as specified in the RStatusCode enumeration.
 
====Returns====
 
<div style="margin-left: 2em;">The type of error that occurred - RLPy.RStatusCode
 
</div>
 
-----
 
===IsError===
 
<syntaxhighlight lang="Python">
 
RLPy.RStatus.IsError ( self )
 
</syntaxhighlight>
 
Determines whether there is an error.
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''true''' An error has occurred.
+
=== IsError( self ) ===
  
'''false''' The operation was successful
+
Check whether the current status is an error.
</div>
+
 
 +
==== Returns ====
 +
:'''true''': An error has occured.
 +
:'''false''': No error.
 +
 
 +
<syntaxhighlight lang="Python">
 +
if status == RLPy.RStatus.Failure:
 +
    print(status.IsError())                        #True
 +
</syntaxhighlight>

Revision as of 00:47, 23 March 2020

Main article: Modules. Last modified: 03/23/2020

Description

This class facilitates error handling for each API. It encapsulates the status code as a return value for each API function. Developers can query, set, or output status codes through this class. The RStatus codes and their instructions are listed below:

Constant Value
RStatus.Success The operation was successful.
RStatus.Failure The operation failed.
RStatus.InsufficientMemory The operation failed due to insufficient memory.
RStatus.LicenseFailure Application is not licensed for the attempted operation.
RStatus.IncompatibleVersion The applied operation is not compatible with the current version.
RStatus.InvalidParameter An invalid parameter was provided.
RStatus.UnknownParameter The operation was called with an unrecognized argument.
RStatus.NotImplemented This operation has not been implemented.
RStatus.Deprecated This operation has been deprecated.
RStatus.NotFound Not currently used.
RStatus.EndOfFile Not currently used.
status = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
   
if status == RLPy.RStatus.Success:
    print("sucess")                                 # print sucess
   
if status == RLPy.RStatus.Failure:
    print("failure")
    status.Clear()
    print(status.IsError())                         # False
   
if status.GetStatusCode() == RLPy.RStatus.Success:
    print("sucess")                                 # print sucess
   
print(status.IsError())

Member Functions

Clear( self )

Clear the current error status. Success status code is returned upon calling this function.

See also: IsError( self )

status = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
if status == RLPy.RStatus.Failure:
    print("failure")
    status.Clear()
    print(status.IsError())  # False

GetStatusCode ( self )

Get the current status code. Refer to the status code table above.

Returns

Return the internal status code - int
  • RLPy.RStatus.Success
  • RLPy.RStatus.Failure
  • RLPy.RStatus.InsufficientMemory
  • RLPy.RStatus.LicenseFailure
  • RLPy.RStatus.IncompatibleVersion
  • RLPy.RStatus.InvalidParameter
  • RLPy.RStatus.UnknownParameter
  • RLPy.RStatus.NotImplemented
  • RLPy.RStatus.Deprecated
  • RLPy.RStatus.NotFound
  • RLPy.RStatus.EndOfFile
if status.GetStatusCode() == RLPy.RStatus.Success:
    print("sucess")                                 # print sucess

IsError( self )

Check whether the current status is an error.

Returns

true: An error has occured.
false: No error.
if status == RLPy.RStatus.Failure:
    print(status.IsError())                        #True