If an error occurs, the operation can be aborted, and (hopefully,) prevent corruption of the model.
- Code: Select all
begin
op_name = "My Operation"
model.start_operation( op_name )
#
### indented code statements here
#
model.commit_operation
rescue => e
model.abort_operation
puts("Error #<#{e.class.name}:#{e.message}.>")
puts(e.backtrace) if $VERBOSE
else
#
# Do code here ONLY if NO errors occur.
#
ensure
#
# ALWAYS do code here errors or not.
#
end