All ThreatConnect ™ Exchange Apps should deliberately exit with the appropriate exit code on completion or failure of execution. The
TcEx Framework provides the
exit_code() methods to handle exit codes. All Apps should end with the
Providing a proper exit code for Playbook Apps is important for execution of downstream Apps.
Setting Exit Code¶
Some failures do not warrant an immediate exit. In such case the
exit_code() method allows an exit code to be set for when the
exit() method is called. This allows the app to continue execution and still notify the ThreatConnect Platform that a failure occurred.
1 2 3 4 5 6 7 8 9 10 11 12
tcex = TcEx() <...snipped> try: with open(datafile, 'r') as fh: data = fh.read() except: tcex.exit_code(3) <snipped...> tcex.exit()
Immediate Exit on Failure¶
Certain failures require that the App exit immediately. In these cases calling the
exit() method while passing the exit code will immediately halt execution of the App and notify the ThreatConnect Platform of a failure.
1 2 3 4 5 6 7 8 9 10
tcex = TcEx() <...snipped> try: with open(datafile, 'r') as fh: data = fh.read() except: tcex.exit(1) <snipped...>
Supported Exit Codes¶
- 0 - Successful execution of App
- 1 - Failed execution of App
- 3 - Partial failure of App