Difference between revisions of "IC Python API:Error Handling"

From Reallusion Wiki!
Jump to: navigation, search
(Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}")
 
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}
 
{{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}}
 +
 +
iClone will attempt to parse scripts that are loaded into the environment.  In most cases, it does a decent job at catching errors and raising issues within the the Console Log.  However, in cases where the errors occur in a loop or sequence, a resulting stack overflow can cause the program to shutdown prematurely.  With no chance for a print-out combined with a lack of session logs, the user can find it hard to pin-point the time and point of occurrence of the error.  Developers are advised to pay special attention to areas of the code that rely on repeated calls to a set of functions.  You can use Python's native '''Try, Except, Finally''' error handling to debug and help fool-proof exceptionally vulnerable segments of your code.
 +
 +
== Exceptions in Python ==
 +
 +
Python has many built-in exceptions which forces your program to output an error when something in it goes wrong. When these exceptions occur, it causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash. For example, if function A calls function B which in turn calls function C and an exception occurs in function C. If it is not handled in C, the exception passes to B and then to A. If never handled, an error message is spit out and our program come to a sudden, unexpected halt. Having the program come to a halt and give details about the error is much more preferable to a program crash.

Revision as of 19:35, 17 February 2020

Main article: RL Python Samples.

iClone will attempt to parse scripts that are loaded into the environment. In most cases, it does a decent job at catching errors and raising issues within the the Console Log. However, in cases where the errors occur in a loop or sequence, a resulting stack overflow can cause the program to shutdown prematurely. With no chance for a print-out combined with a lack of session logs, the user can find it hard to pin-point the time and point of occurrence of the error. Developers are advised to pay special attention to areas of the code that rely on repeated calls to a set of functions. You can use Python's native Try, Except, Finally error handling to debug and help fool-proof exceptionally vulnerable segments of your code.

Exceptions in Python

Python has many built-in exceptions which forces your program to output an error when something in it goes wrong. When these exceptions occur, it causes the current process to stop and passes it to the calling process until it is handled. If not handled, our program will crash. For example, if function A calls function B which in turn calls function C and an exception occurs in function C. If it is not handled in C, the exception passes to B and then to A. If never handled, an error message is spit out and our program come to a sudden, unexpected halt. Having the program come to a halt and give details about the error is much more preferable to a program crash.