Closed jose1711 closed 1 year ago
You could define, raise and catch a custom error, say ScriptTerminateError
.
# define the custom error
class ScriptTerminateError(Exception):
pass
def some_other_procedure():
# throw an an ScriptTerminateError
raise ScriptTerminateError
def print_something():
print("foo")
some_other_procedure()
def script_main():
print_something()
# wrap the invocation of the main method in a try .. except block.
# The code flow will end up here whenever you raise a
# ScriptTerminateError somewhere in the script.
try:
script_main()
except ScriptTerminateError:
print("Script terminated with a termination error")
While using jython backend - please what is the best way to stop execution of the script (without resorting to if.. then..)? Tried with
System.exit(0)
but that terminates the whole application (JOSM). Thank you.